springboot thymeleaf org.xml.sax.SAXParseException错误

SpringBoot越来越受欢迎,而官方推荐的模板是thymeleaf ,但是其语法太过严格,使用过程中一不留心就会出现org.xml.sax.SAXParseException错误

其中主要是下面这些标签没有被正确关闭

<link>  <meta>  <head>  <hr>  <img>
<link/>  <meta/>  <head/>  <hr/>  <img/>

另外在thymeleaf 模板里使用js写>,<等符号都会报错,这里有一个方法很实用

<script type="text/javascript">
        //<![CDATA[/**获得当前日期**/
        function  getDate01(){
            var time = new Date();
            var myYear = time.getFullYear();
            var myMonth = time.getMonth()+1;
            var myDay = time.getDate();
            if(myMonth < 10){
                myMonth = "0" + myMonth;
            }
            document.getElementById("yue_fen").innerHTML =  myYear + "." + myMonth;
            document.getElementById("day_day").innerHTML =  myYear + "." + myMonth + "." + myDay;
        }//]]>
    </script>

就是用<![CDATA[ ]]>标签,在标签里面写js就不会报错,另外js可能会报无法识别<的错误,这时在其前面加上//即可,如上图所示


原文地址:https://www.cnblogs.com/lwx521/p/10182948.html

时间: 2024-10-07 01:40:34

springboot thymeleaf org.xml.sax.SAXParseException错误的相关文章

坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException

今天整整一个上午都在和hibernate做斗争,早上一来,继续昨天的项目开发,发现spring项目不能启动,从错误中看是hibernate错误,多半是hibernate配置有错误,关键是错误提示中显示“com.mdnet.travel.core.dao.ValidCodeDAOImpl”不能注入,经过仔细查看未见异常,而且这个文件好久没有改过了.没办法把hibernate的配置改成如下配置: <bean id="sessionFactory" class="org.sp

Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)

本文原文连接: http://blog.csdn.net/bluishglc/article/details/7596118 ,转载请注明出处! 有时候你会发现过去一直启动正常的系统,某天启动时会报出形如下面的错误: [plain] view plaincopy org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/sche

转载:sax错误:org.xml.sax.SAXParseException: Content is not allowed in prolog解决

原因及其解决办法: 1.xml编码错误 该xml是UTF-8编码的,如果该文件通过UltraEdit编辑后,会在无BOM头的UTF-8文件中加入BOM,但是DOM4j不认这个BOM(dom4j1.3),解决的办法可以通过升级dom4j到1.6解决www.dom4j.org 什么是BOM?http://www.unicode.org/faq/utf_bom.html#22Unicode规范中有一个BOM的概念.BOM——Byte Order Mark,就是字节序标记.在这里找到一段关于BOM的说明

Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from file [E:\Ecl

(Spring加载xml时)org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element &#39;beans&#39;.

ApplicationContext ctx = new ClassPathXmlApplicationContext("test.xml");报错 在启动Spring时,报以下错误,如图: 原因是在xml中spring的xsd的版本配置的不一致,我使用的是spring-2.5.6,但配置文件中配的是3.0.改成如下即可: [xhtml] view plain copy <?xml version="1.0" encoding="UTF-8"

xml操作-Nested exception: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 异常处理

异常如下: org.dom4j.DocumentException: Error on line 2 of document file:///D:/workspaces/struts2/lesson01/src/newfile.xml : White spaces are required between publicId and systemId. Nested exception: White spaces are required between publicId and systemId

Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 84; 对实体 &quot;characterEncoding&quot;

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from class path

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

Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.    at org.apache.ibatis.parsing.XPathParser.

Caused by: org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 81;

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 28 in XML document from class path