---
title: "The reference to entity \"characterEncoding\" must end with the ';' delimiter  "
author: "flashdream8"
date: "2014-01-13T15:04:41Z"
tags: []
categories: ["编程语言"]
slug: "the-reference-to-entity-characterencoding-must-end-with-the-delimiter"
draft: false
lastmod: "2014-01-13T15:04:41Z"
id: 2003356
url: "https://flashdream8.iteye.com/blog/2003356"
---

数据源配置时加上编码转换格式后出问题了：

 

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

 

这个错误就是 context.xml中设置数据源链接URL的问题   

 

&lt;context-param&gt;

 

    &lt;param-name&gt;url&lt;/param-name&gt;

 

    &lt;param-value&gt;jdbc:mysql://localhost:3306/bookstore?useUnicode=true&characterEncoding=UTF-8&lt;/param-value&gt;

 

&lt;/context-param&gt;

 

正确的如下：

 

&lt;context-param&gt;

 

    &lt;param-name&gt;url&lt;/param-name&gt;

 

    &lt;param-value&gt;jdbc:mysql://localhost:3306/bookstore?useUnicode=true&amp;characterEncoding=UTF-8&lt;/param-value&gt;

 

&lt;/context-param&gt;

 

这大概是由xml文件中的编码规则决定要这么变换。

 

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

&lt;

&lt;

小于号

&gt;

&gt;

大于号

 

&amp;

&

和

 

&apos;

'

单引号

&quot;     "       双引号