springboot 模板可能不存在,也可能不被任何配置的模板解析器访问。

一、如果返回的是jsp页面,或者html,@Controller配合视图解析器InternalResourceViewResolver才行。

 

需要在application.properties配置文件

spring.thymeleaf.prefix=classpath:/templates/

spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html # ;charset=<encoding> is added

spring.thymeleaf.cache=false

 

二、如果需要返回JSON,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。

 

以上两者都会报以下错误

template might not exist or might not be accessible by any of the configured Template Resolvers

 

posted @ 2018-09-10 13:58  别皱眉!  阅读(2333)  评论(0编辑  收藏  举报
https://user.qzone.qq.com/1689809710/infocenter