Springboot2.1.1使用thymeleaf


访问页面只返回字符串

查看controller中是否注解了@RestController将其修改注解为@Controller。

RestController = Controller + ResponseBody。

加RestController,返回是你return中的内容。如是return "success"页面只是显示success

Controller,返回的是return中对应的页面,如return “success” 返回的是success.html

访问页面的时候还出错注释掉一下内容

<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>

如果springboot是用1.5的版本的 那时候thymeleaf默认版本是2,需要使用3版本要添加如下版本号:thymeleaf.version 为3.0.9
还有thymeleaf-layout-dialect.version为2.1.1那个配置。 而我的springboot是2.1.1版本的,加了这个就找不到thymeleaf的版本了,
也就找不到thymeleaf了,动态网页就无法显示。所以去掉这两行就可以了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM