thymeleaf能自己定义变量吗?

我想在页面定义自己的变量。就像jsp的<c:set var="currentMod" value="bbs" scope="page"></c:set>一样

但是thymeleaf好像没有办法?

阅读 10.8k
1 个回答
新手上路,请多包涵

亲测可用

<head th:with="component =${'/static/component'}, bizJs = ${'/static/js/biz'}" >
    <span th:text="${component}"></span>
    <script th:src="@{(${component})}"></script>
    <script th:src="@{${bizJs} + '/static/js'}"></script>
</head>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题