抽取公共页面
处理table页面下的跳转,新建一个tableController类,负责table的所有页面的响应设置
@Controller
public class TableController {
@GetMapping("/basic_table")
public String basic_table(){
return "table/basic_table";
}
@GetMapping("/dynamic_table")
public String dynamic_table(Model model){
return "table/dynamic_table";
}
@GetMapping("responsive_table")
public String responsive_table(){
return "table/responsive_table";
}
@GetMapping("editable_table")
public String editable_table(){
return "table/editable_table";
}
}
抽取公共页面是属于前端的,在前端的设计中,有很多公共使用的部分,就可以把这些很多页面都是用的部分抽取出来,简化开发
比如将公共使用的部分全部选取出来放在common.html中
在Thymeleaf语法的写法
<body>
<div th:fragment="copy">
© 2011 The Good Thymes Virtual Grocery
</div>
</body>
也可以使用id
<body>
<div id="copy-session">
© 2011 The Good Thymes Virtual Grocery
</div>
</body>
在引用的时候也是存在三种语法
<body>
...
<div th:insert="footer :: copy"></div>
<div th:replace="footer :: copy"></div>
<div th:include="footer :: copy"></div>
</body>
三种引用方法的区别
<body>
...
<div>
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
</div>
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
<div>
© 2011 The Good Thymes Virtual Grocery
</div>
</body>
注意:footer :: copy 中的footer是文件名,而不是标签名