thymeleaf取model值_Thymeleaf-取值1、基于“置顶-SpringBoot-最终整合”进⾏
2、导⼊pom:
org.springframework.boot
spring-boot-starter-thymeleaf
kohtml
nekohtml
1.9.22
3、application.properties配置
#thymeleaf模板配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
de=LEGACYHTML5
ding=UTF-8
t-type=text/html
4、控制器
package ller;
thymeimport org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/system")
public class TestThymeleafController {
/
**
*
* Thymeleaf
* @author 开发者
*
*/
@RequestMapping("thy")
public String thy(Model model){
model.addAttribute("host","Thymeleaf");
return "hello";
}
}
5、在resources下的templates⽂件夹,创建hello.html Thymeleaf
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论