Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 带thymeleaf转义字符的内联javascript_Spring_Thymeleaf_Html Escape Characters - Fatal编程技术网

Spring 带thymeleaf转义字符的内联javascript

Spring 带thymeleaf转义字符的内联javascript,spring,thymeleaf,html-escape-characters,Spring,Thymeleaf,Html Escape Characters,我用百里香和春天。 我尝试使用内联javascript <script th:inline="javascript"> $("#genericTable").bootstrapTable({ url: /*[[${url}]]*/ 'generic', ... }); 我明白了 url:“\/rest\/vehicles” 为什么要将某些字符添加到字符串中 编辑 与 first/类似于removed,因此调用…无效。您可以

我用百里香和春天。 我尝试使用内联javascript

<script th:inline="javascript">

    $("#genericTable").bootstrapTable({
        url: /*[[${url}]]*/ 'generic',
        ...
     });    
我明白了

url:“\/rest\/vehicles”

为什么要将某些字符添加到字符串中

编辑


first/类似于removed,因此调用…无效。

您可以尝试以下方法:

<script type="text/javascript" th:inline="javascript">
  /*<![CDATA[*/
    $("#genericTable").bootstrapTable({
        url: /*[[${url}]]*/ 'generic',
        ...
    });  
  /*]]>*/
</script>

/**/
[(…)]
应该有帮助

我面临的问题示例:

$.getJSON('[[@{/management/users/search/unit/}]]' + value, function(data) {
转换为:

$.getJSON('"\/management\/users\/search\/unit\/"' + value, function(data) {
$.getJSON('/management/users/search/unit/' + value, function(data) { 
使用
[(…)]

转换为:

$.getJSON('"\/management\/users\/search\/unit\/"' + value, function(data) {
$.getJSON('/management/users/search/unit/' + value, function(data) { 

请注意,[…]对应于th:text(即结果将是HTML转义),[(…)]对应于th:utext,并且不会执行任何HTML转义


我知道这个问题有点老了,但答案并不能纠正问题,或者和我面临的问题一样。要删除转义,我建议编写如下代码(此处双引号仅用于javascript目的):


/**/

很抱歉,我不明白:你会得到哪些额外的字符?我更新了,\character是addedJ。我想这是因为它对/(进行了某种转义)。这就是为什么URL有一种特殊的语法。看这里,有一个关于URL重写的部分。您是否尝试在Javascript注释之外生成它?例如,直接在HTML中作为文本(当然使用@)。如果你得到什么?如果我只使用:@{${url}没有生成任何内容请注意,这个答案是从2017年9月开始的,这些年来情况可能发生了变化。。。
$.getJSON('/management/users/search/unit/' + value, function(data) {