一、如果返回的是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
