1,添加jar
<!--themplates模板-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2,在 項(xiàng)目 src\main\resources\templates 下新建 login.html
3,在controller層跳轉(zhuǎn)頁面‘
@Controller //注意這里只能controller 不能RestController
@RequestMapping(value="/index")
public class IndexController {
@RequestMapping(value="/aa",method= RequestMethod.GET)
public String test(HttpServletRequest request) {
//邏輯處理
request.setAttribute("key", "hello world"); //向前臺傳參
return "login"; //跳轉(zhuǎn)到頁面
}
}
4,前臺接受傳參
<body>
themplates模板
[[${key}]] //接受的值
</body>
5椭员,tmpl的html 讀取靜態(tài)配置的路徑
![IMG_20190219_112736406.jpg](https://upload-images.jianshu.io/upload_images/12197462-9a7170a0e36221ca.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
<script src="/layui/layui.js"></script>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" >
<link rel="stylesheet" href="/layui/css/layui.css" media="all" >
這2 個(gè)方法都可以.因?yàn)閘ayui在webapp下面 所以 去掉 wabapp 換成 / 下面就寫全路徑