XML报错:The reference to entity "characterEncoding" must end with the ';' delimite

解决方法:

在web.xml增加如下配置:
<filter> 
<filter-name>encodingFilter</filter-name> 
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
<init-param> 
<param-name>encoding</param-name> 
<param-value>UTF8</param-value> 
</init-param> 
<init-param> 
<param-name>forceEncoding</param-name> 
<param-value>true</param-value> 
</init-param> 
</filter>

 

然后再改一下数据库连接
jdbc:mysql://localhost/mydb?useUnicode=true&characterEncoding=utf-8

然后在MYSQL软件中更改对应字段为UTF-8编码;

 

纠错结果:

在配置一个访问数据库的Url时,第一次设置的内容如下:

jdbc:mysql://localhost:3306/photo?useUnicode=true&characterEncoding=UTF-8,注意中间那个“&”,在xml中这个是读不出的,正确写法将“&”转义“&amp;”:

jdbc:mysql://localhost:3306/photo?useUnicode=true&amp;characterEncoding=UTF-8

分析:

有时候在使用xml作为配置文件的时候,应该要使用xml的编码规则来进行适当的设置。

下面给出xml中一些特殊符号的编码转换

 &lt;  <  小于号
 &gt;  >  大于号
 &amp;  &  and字符
 &apos;  '  单引号
 &quot;  "  双引号
posted @ 2018-05-10 21:13  Final_static_杨  阅读(190)  评论(0编辑  收藏  举报