在配置Spring 的数据源的时候,想把url配置下面加一个mysql数据库的编码格式的处理..

 

刚开始是这么写的:

<property name="url" value="jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8"/>


 

启动服务,就提示

The reference to entity "characterEncoding" must end with the ';' delimiter

错误.

 

后面改成:


<property name="url" value="jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8"/>


 

就没错误了,因为在解析的时候,会进行转义操作.

 

在xml文件中有以下几类字符要进行转义替换:

 

 

&lt;

 

<

 

小于号

 

&gt;

 

>

 

大于号

 

&amp;

 

&

 

 

&apos;

 

'

 

单引号

 

&quot;

 

"

 

双引号

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6