ApacheCrazyFan 2018-08-06 08:04 采纳率: 100%
浏览 8702
已结题

springboot配置thymeleaf

application.properties:

 #thymeleaf
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.contentType=text/html
spring.thymeleaf.cache=false

视图返回:

 /**
     *
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/user/login").setViewName("canal/user/login");
        registry.addViewController("/user/index").setViewName("canal/user/user_index");
    }

结构目录:
图片说明

报警告:

 2018-08-06 15:46:12.829  INFO 4416 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/user/login] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2018-08-06 15:46:12.829  INFO 4416 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/user/index] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2018-08-06 15:46:12.838  INFO 4416 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 15:46:12.839  INFO 4416 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 15:46:12.839  INFO 4416 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/static/canal/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 15:46:12.893  WARN 4416 --- [           main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2018-08-06 15:46:13.167  INFO 4416 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-06 15:46:13.169  INFO 4416 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'druidDataSource' has been autodetected for JMX exposure
2018-08-06 15:46:13.178  INFO 4416 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'druidDataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=druidDataSource,type=DruidDataSource]
2018-08-06 15:46:13.231  INFO 4416 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat started on port(s): 8080 (http) with context path '/CANAL'
2018-08-06 15:46:13.237  INFO 4416 --- [           main] c.Application                            : Started Application in 3.552 seconds (JVM running for 4.212)

访问: localhost:8080/CANAL/user/login
出现:



    2018-08-06 16:03:36.778 ERROR 4416 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/CANAL] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "canal/user/login", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
     org.thymeleaf.exceptions.TemplateInputException: Error resolving template "canal/user/login", template might not exist or might not be accessible by any of the configured Template Resolvers  
     at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:870) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:354) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]


  • 写回答

5条回答

  • ApacheCrazyFan 2018-08-06 08:07
    关注

    thymeleaf:
    图片说明

    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用