且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-09-18 11:46:35

  在实现Java数据池时,进行配置数据源时出现了该报错信息。报错信息出现在 context.xml 中,原语句是:

<Context>    

   <Resource name="jdbc/onlinefriend"

    auth="Container" 

    type="javax.sql.DataSource"         

     driverClassName="com.mysql.jdbc.Driver"    

     url="jdbc:mysql://127.0.0.1:3306/onlinefriend?useUnicode=true&characterEncoding=utf-8"

     username="root"  

     password="root" 

     maxActive="100"  

     maxIdle="30"  

     maxWait="10000"    />    

 </Context>  


这是由于xml的编码问题导致,小小的修改后问题解决:

<Context>    

   <Resource name="jdbc/onlinefriend"

    auth="Container" 

    type="javax.sql.DataSource"         

     driverClassName="com.mysql.jdbc.Driver"    

     url="jdbc:mysql://127.0.0.1:3306/onlinefriend?useUnicode=true&amp;characterEncoding=utf-8"

     username="root"  

     password="root" 

     maxActive="100"  

     maxIdle="30"  

     maxWait="10000"    />    

 </Context>  


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

&lt; < 小于
&gt; > 大于
&amp; &
&apos; ' 单引号
&quot; " 双引号


本文转自 pangfc 51CTO博客,原文链接:http://blog.51cto.com/983836259/1697596,如需转载请自行联系原作者