首页 > 其他 > 详细

thymeleaf出现的异常问题02

时间:2019-05-30 15:32:12      阅读:138      评论:0      收藏:0      [点我收藏+]

SpringBoot+Thyemleaf开发环境正常,打包jar发到服务器就报错Template might not exist or might not be accessible

1. 在controller层请求处理完了返回时,没有使用@RestController或@ResponseBody而返回了非json格式

2. 在你的controller层对应的方法返回html路径及名称时,在前面多加了一个/ 。

例如return "/index",正式这个/导致报错的,解决:去掉返回前面的/即可,例如return "index" 。

3. 在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。

#thymeleaf
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
再在pom.xml 添加以下依赖

  1. <dependency>
  2. <groupId>net.sourceforge.nekohtml</groupId>
  3. <artifactId>nekohtml</artifactId> 
  4. <version>1.9.22</version>
  5. </dependency>

thymeleaf出现的异常问题02

原文:https://www.cnblogs.com/lazyli/p/10949717.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!