重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
這篇文章主要為大家展示了“SpringBoot如何使用thymeleaf模板”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“SpringBoot如何使用thymeleaf模板”這篇文章吧。
1.導(dǎo)入依賴
2.application.yml文件中新增thymeleaf配置
###配置thymeleafspring: thymeleaf: cache: false
3.創(chuàng)建實體類
public class Student { private Integer stu_id; private String stu_name; public Integer getStu_id() { return stu_id; } public void setStu_id(Integer stu_id) { this.stu_id = stu_id; } public Student(Integer stu_id, String stu_name) { this.stu_id = stu_id; this.stu_name = stu_name; } public String getStu_name() { return stu_name; } public void setStu_name(String stu_name) { this.stu_name = stu_name; }}
4.在src/main/resource文件夾下創(chuàng)建templates文件夾
并創(chuàng)建一個index.html以備后續(xù)使用
5.創(chuàng)建一個ThyController類
@Controller@RequestMapping("/thyController")public class ThyController { @RequestMapping("/thymeleaf") public String thymeleaf(Model model){ List
6.hello.html頁面
7. 瀏覽器測試
以上是“SpringBoot如何使用thymeleaf模板”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!