关于thymeleaf中th:insert、th:replace、th:include的区别

  1. th:insert:保留自己的主标签,保留th:fragment的主标签
需要替换的片段内容:
 2 
3 4
5 6 导入片段: 7
8 9 10 结果为: 11
12
13 14
15
  1. th:replace:不保留自己的主标签,保留th:fragment的主标签
需要替换的片段内容:
 2 
3 4
5 6 导入片段: 7
8 9 结果为: 10
11 12
  1. th:include:保留自己的主标签,不保留th:fragment的主标签(官方3.0不推荐)
需要替换的片段内容:
 2 
3 4
5 6 导入片段: 7
8 9 结果为: 10
11 12

你可能感兴趣的:(thymeleaf,前端)