配备JNDI 报错 The reference to entity "characterEncoding" must end with th

配置JNDI 报错 The reference to entity characterEncoding must end with the delimiterContext pat

配置JNDI 报错 The reference to entity "characterEncoding" must end with the ';' delimiter

<Context path="/bizsample" docBase="E:/行业版/eclipse/workspace/bizsample/WebApp">
 <Resource auth="Container"
  name="jdbc/bizsample"
  type="MySql"
  maxActive="3306"
  maxIdle="4"
  maxWait="10"
  username="root"
  password="admin"
  driverClassName="com.mysql.jdbc.Driver"
  url="jdbc:mysql://localhost:3306/test?useUnicode=true;characterEncoding=utf-8" />
</Context>

上边这种配置方式 会报The reference to entity "characterEncoding" must end with the ';' delimiter 这个错误。

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

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

&lt;

<

小于号

&gt;

>

大于号

&amp;

&

&apos;

'

单引号

&quot;

"

双引号

正确的方式

<Context path="/bizsample" docBase="E:/行业版/eclipse/workspace/bizsample/WebApp">
 <Resource auth="Container"
  name="jdbc/bizsample"
  type="MySql"
  maxActive="3306"
  maxIdle="4"
  maxWait="10"
  username="root"
  password="admin"
  driverClassName="com.mysql.jdbc.Driver"
  url="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8" />
</Context>