thymeleaf: reference entity "XXX" must start with ';' end with a delimiter

Today, found that the error in which a spring boot Micro services:

org.xml.sax.SAXParseException: entity "isdialog" reference must start with ';' end with a delimiter.

Analysis found that JavaScript in the page url using the "&" symbol can not identify the cause, thymeleaf pot. Under normal circumstances we only use boot server provides an interface to write, engage the front and rear ends of the splitter is no problem, because the demand for this relatively simple, so direct in boot project added a few static pages, the result of taking the default boot thymeleaf the resolution, engage in such a complex.

Under Record Solution (js emergency only simple modifications to the project):

Use js / * <! [CDATA [* / / *]]> * / wrapped up, to normal parsing.

<script th:inline="javascript">
/*<![CDATA[*/
function open3(){
    window.open('http://xxxxx:8080/yyyy/&isdialog=1&id=892267');
}
/*]]>*/
</script>

 

analysis:

thymeleaf grammar too strict, more rigid, especially for html5 support is not very good. If the project is selected in the selection thymeleaf, it can be considered to remove her strict verification would be better.

1, rely on the introduction of maven

<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
</dependency>

2, application.prpoerties configuration changes

spring.thymeleaf.mode=LEGACYHTML5 #设置为LEGACYHTML5编码格式
spring.thymeleaf.cache=false #关闭页面缓存

 

Published 125 original articles · won praise 116 · views 20000 +

Guess you like

Origin blog.csdn.net/shipfei_csdn/article/details/103760898