thymeleaf 中导入html

clipboard.png
如图所示,有太多的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中该如何处理呢?

阅读 9.9k
2 个回答

在templates下新建个common.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">

<head>

<meta charset="UTF-8"/>
<link th:href="@{/plugin/jquery-easyui-1.5.2/themes/icon.css}" rel="stylesheet"/>
<link th:href="@{/plugin/jquery-easyui-1.5.2/themes/default/easyui.css}" rel="stylesheet"/>
<script th:src="@{/plugin/jquery/jquery-3.2.1.js}"></script>

</head>
</html>
在其他页面使用:
<head th:include="common">

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题