[英]Insert Thymeleaf fragments in Javascript
我正在将Spring Boot 1应用程序迁移到Spring Boot2。在原始应用程序中,我看到很多类似这样的片段:
<script th:inline="javascript">
<th:block th:include="fragments/script :: actionsMenu-js"/>
$(document).ready(function() {
...
});
现在使用Thymeleaf 3,即使更改了include插入后,它似乎也不再起作用:
<script th:inline="javascript">
<th:block th:insert="~{fragments/script :: actionsMenu-js}"/>
$(document).ready(function() {
...
});
没有插入该块并且Javascript不正确,我得到:
messages:180 Uncaught SyntaxError: Unexpected token <
我可以去编辑所有页面,然后将代码块放在脚本之外,但是我更喜欢一种不需要重构的方法。
如果您改用TEXT语法,是否可行?
[# th:insert="~{fragments/script :: actionsMenu-js}" /]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.