本人的Thymeleaf配置:
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
当在Controller层进行return "redirect:/xxxx";或者return "xxx";
页面中显示字符串,有以下几种可能的错误原因:
①在SpringBoot框架下进行开发,使用@RestController注解,会导致所有的方法都会自动进行@ResponseBody(即返回json字符串),不经过Thymeleaf配置的视图解析,从而导致页面现实字符串。
②检查/index接口下的路径是否正常正确,如果错误,也会导致无法正常解析
出现错误:Error resolving template [front/index], template might not exist or might not be accessible by any of the configured Template Resolvers