springboot加载templates下html打印的是返回的字符串

今天遇到了这个问题,在templates下html页面打印的只是返回的字符串,而不是页面内容,经过查询找到了解决方法

错误原因:是因为在controller类中使用了 @RestController 注解(补充 : 如果加上注解 @ResponseBody 也会出现相同情况)

解决办法:将@RestController改为 @Controller 在访问就可以了

以下是原文链接

https://blog.csdn.net/a1194821568/article/details/90719896

posted @ 2019-10-09 17:14  一盘土豆泥  阅读(1077)  评论(0)    收藏  举报