本文共 1101 字,大约阅读时间需要 3 分钟。
1.如何Spring Boot整合Web开发-如何集合模板Thymeleaf?
步骤一:pom.xml加入Thymeleaf依赖
org.springframework.boot spring-boot-starter-thymeleaf
步骤二:thymeleaf有一些配置如何在网上查找? 输入https://spring.io 然后Projects里选择SpringBoot 然后选LEARN,下载DOC讲解文档
步骤三:在src/main/resources下的 application.properties属性文件中配置thymeleaf spring.thymeleaf.cache=false
#thymeleafspring.thymeleaf.cache=false
步骤四:src/main/resources/templates下的thymeleaf.html
This is a Thymeleaf page This is Thymeleaf page!
步骤五:ThymeleafController
package com.springboot.demo.SpringBootDemoProject.thymeleaf;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.RequestMapping;//必须和前台交互就不能用RestController@Controller@RequestMapping("t")public class ThymeleafController { @RequestMapping("show") public String show(ModelMap model) { model.addAttribute("welcome", "Welcome to my website!"); return "thymeleaf"; }}
转载地址:http://trzqf.baihongyu.com/