gpt4 book ai didi

java - 大于 > 小于 < 在 thymeleaf javascript 内... 错误 : The content of elements must consist of well-formed character data or markup

转载 作者:IT老高 更新时间:2023-10-28 13:48:02 26 4
gpt4 key购买 nike

当我尝试插入 < 时出现此错误或 > thymeleaf 中的运算符javascript。

我的代码

<script th:inline="javascript">
$(document).ready(function () {
...
if(timeRemain < 0){
...
}
...
var result = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
...
});
</script>

错误信息

org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.

我该如何解决这个问题?

最佳答案

通过将 CDATA 添加到 script 标记来解决此问题,如下所示

<script th:inline="javascript">
/*<![CDATA[*/
...
...
...
/*]]>*/
</script>

关于java - 大于 > 小于 < 在 thymeleaf javascript 内... 错误 : The content of elements must consist of well-formed character data or markup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29540489/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com