`
liuzhaodong89
  • 浏览: 59864 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

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

 
阅读更多

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

 

Caused by: org.xml.sax.SAXParseException: The reference to entity "test" must end with the ';' delimiter.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
        ... 176 more

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

分享到:
评论
1 楼 sunnylovewindy 2013-04-27  
非常感谢!帮上忙了!

相关推荐

Global site tag (gtag.js) - Google Analytics