一、Thymeleaf
第一个容易报错的点在自己配置的视图解析中
1.注意addViewControllers中的页面访问路径配置
2.localeResolver注意它是不是小写,一定不能是大写
3.@Bean一定要加上
第二个容易报错的点在MyLocaleResolver配置中
1.获取请求中的语言链接一定要与前端的设置一样尽量为lang
二、org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates//views/index.html]")
解决思路,排查法
1.找到报错的页面
2.去掉页面中所有信息查看是否可以跳转
3.如果不能跳转说明是controller接口的问题,去对比接口
4.如果能运行请一段一段往里面添加自己写的html代码,这样可以快熟的找到问题
5.如果这些都不行试试把下面的配置加入yaml或propererties,这些是主流的解决报这个错的方法Thymeleaf方法
#配置无法渲染的页面(这个我也不是很懂因为好像不设置也可以) spring.thymeleaf.return = "index"; #thymeleaf的配置 #这里应该是指定识别模式文档(这个我也不是很懂因为好像不设置也可以) spring.thymeleaf.content-type=text/html #这里是指定因为thymeleaf只能与html5匹配,所以这里设置匹配模式 spring.thymeleaf.mode=LEGACYHTML5 #设置自己html存放的逻辑让thymeleaf可以扫描 pring.thymeleaf.prefix=classpath:/templates/views/*.html #设置编码格式 spring.thymeleaf.encoding=UTF-8