I get this error when I try to insert <
or >
operators inside the thymeleaf
javascript.
My code
<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>
Error message
org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
How can i solve this?
This issue is solved by adding CDATA
to the script
tag as below
<script th:inline="javascript">
/*<![CDATA[*/
...
...
...
/*]]>*/
</script>
Apart from using CDATA you can also encode < as <
and > as >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With