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