[英]Inline thymeleaf property into Javascript
I am trying to inline a Spring application.properties entry into Javascript. 我试图将Spring application.properties条目内联到Javascript中。
Works fine: 工作正常:
<h1 th:utext="${@environment.getProperty('key')}"></h1>
Produces null: 产生空值:
<script th:inline="javascript">
/*<![CDATA[*/
...
var user = /*[[${key}]]*/ null;
...
/*]]>*/
</script>
What is the correct syntax? 正确的语法是什么? When I try to use @environment inside the script tag I get another error:
当我尝试在脚本标记内使用@environment时 ,出现另一个错误:
Error: $compile:tpload
Error Loading Template
Just 只是
[[${@environment.getProperty('key')}]]
works, without the other stuff, written in the Thymeleaf docs. 可以在Thymeleaf文档中编写,而没有其他内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.