如图所示,有太多的js需要导入了, 所以我想搞个通用的。
比如在jsp中:可以定义一个
<script xxxx</script>
<script xxxx</script>
<script xxxx</script>
<script xxxx</script>
<script xxxx</script>
<script xxxx</script>
<link xxxx css样式/>
<link xxxx css样式/>
<link xxxx css样式/>
全是这种的一个 jsp,然后在index.jsp中 include 即可。
那么,这种情况在thymeleaf中该如何处理呢?
在templates下新建个common.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
<head>
</head>
</html>
在其他页面使用:
<head th:include="common">