一、什么是模版引擎
就是偽html,格式是html,但是可以像jsp那樣有動態(tài)數(shù)據(jù),也可以說是動態(tài)頁面靜態(tài)化。
二、有什么作用
可以提高搜索引擎的搜索
三、有那些模版引擎
velocity 、Thymeleaf、framemaker
velocity相關(guān)資料
Thymeleaf
官方資料:https://www.thymeleaf.org/documentation.html
其它資料1:https://blog.csdn.net/u014042066/article/details/75614906
其它資料2https://www.cnblogs.com/summercanon/p/7910799.html
framemaker
中文教程文檔:https://download.csdn.net/download/ch656409110/4494063
四、使用案例
這里使用:Thymeleaf 作為模版引擎為例:這里只是參考一下。第五步會有完整案例
上代碼:
1、控制層
@Controller
public class ThymeleafTestController {
private Logger logger = LoggerFactory.getLogger(ThymeleafTestController.class);
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String hello(Map<String,Object> maps){
maps.put("name","張三");
maps.put("sex","男");
return "index";
}
}
2、頁面代碼
<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>首頁</title>
</head>
<body>
<!--/*@thymesVar id="name" type="java.lang.String"*/-->
<p th:text="'Hello!, ' + ${name} + '!'" >3333</p>
<p th:text="${sex}">aaa</p>
</body>
</html>
3、效果
效果
五、完整步驟集成到SpringBoot
點(diǎn)這里完整步驟集成到SpringBoot
看相關(guān)其它文章先到:目錄大崗
