在java的xml文件配置数据库URL地址时提示The reference to entity "characterEncoding" must end with the ';' delimiter.错误信息

时间:2024-11-29 10:38:07

配置数据库的URL<property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message"/>,加上参数?useUnicode=true&characterEncoding=UTF-8

<property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message?useUnicode=true&characterEncoding=UTF-8"/>

提示:The reference to entity "characterEncoding" must end with the ';' delimiter.

解决办法:

<property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message?useUnicode=true&characterEncoding=UTF-8"/>注意中间那个“&”,在xml中是读不出的,正确写法是将“&”写成转义形式“&amp;”:
<property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message?useUnicode=true&amp;characterEncoding=UTF-8"/>