thymeleaf初步使用
2024-09-06 23:24:45
thymeleaf模板引擎初步使用
#thymelea模板配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
@RequestMapping("/user")
@Controller
public class IndexController {
@RequestMapping("index")
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("index");
modelAndView.addObject("name","XXX");
return modelAndView;
}
@RequestMapping("home")
public String home(){
return "home";
}
@RequestMapping("/map")
public String map(Map<String,String> map){
map.put("map","map");
return "map";
}
}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 th:text="${name}"></h1>
</body>
</html>
最新文章
- 多个radiobutton选定一个
- XproerIM-v1.3更新-企业即时通迅
- linux 7 常见命令
- 修改iptables防火墙规则解决vsftp登录后不显示文件目录的问题
- 在eclipse中生成html注释文档
- javascript遍历控件(实例详解)
- log4j定义某个类的日志级别
- iOS 之NSJSONReadingOptions说明【转】
- vue-cli的webpack模板项目配置文件分析
- Python-定时爬取指定城市天气(一)-发送给关心的微信好友
- DI是实现面向切面和面向抽象的前提
- tensorflow-mnist报错[WinError 10060] 由于连接方在一段时间后没有正确答复解决办法
- laravel整合vue 多入口解决
- Qt对象树
- java数组的for遍历
- Day08 - Ruby比一比:String的+=与concat串接
- Linux系统中Redis和Tomcat的PID文件路径设置
- java的抽象方法
- Linux用户相关指令
- 创建一个jdbc连接