The reference to entity “test” must end with the ';' delimiter 异常处理【转】

本文转自http://liuzhaodong89.iteye.com/blog/1559998; 

今天修改了配置文件中的一个配置项值,将原先的url连接中加入了一个&source=upload,结果在应用启动的时候报错了。错误栈如下:

 

Java代码   收藏代码
  1. Caused by: org.xml.sax.SAXParseException: The reference to entity "test" must end with the ';' delimiter.  
  2.         at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)  
  3.         at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)  
  4.         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)  
  5.         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)  
  6.         at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)  
  7.         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source)  
  8.         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)  
  9.         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)  
  10.         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)  
  11.         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)  
  12.         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)  
  13.         at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)  
  14.         at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)  
  15.         at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)  
  16.         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)  
  17.         ... 176 more  

上网google,发现是sax解析造成的问题。解决方案很简单,就是把配置项值中用到"&"的地方改成"&"。原因是sax解析的类库在读取文件的时候是根据转义后的格式进行读取的,遇到"&"就认为是一个转义字符串,开始找结束符";",找不到自然就报错了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值