奇怪问题

 

 

控制台报的错误

The processing instruction target matching "[xX][mM][lL]" is not allowed.

 

Nested exception: 
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
	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.XMLScanner.scanPIData(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.scanPI(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.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.AbstractSAXParser.parse(Unknown Source)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.io.SAXReader.read(SAXReader.java:264)
	at com.ebb365.util.tool.Dom4jDemo.loadItemList(Dom4jDemo.java:406)
	at com.ebb365.web.action.siteindex.HomeSiteIndex.execute(HomeSiteIndex.java:166)
	at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)

 

 

出现的原因

一、

正如网上说的,XML文件头部有空格

参考:http://jolestar.iteye.com/blog/56828

二、

我发现的原因,XML 文件里面出现了特殊字符,像"&",后来我想用其他字符代替,像用"+"等均错,后来我把 & 的参数去掉,一切正常,加上又错。

解决办法:还是用某一个特定字符或数字代替,具体用哪个按自己喜好来吧。

 

<?xml version="1.0" encoding="GBK"?>

<bcaster config="2|0xffffff|0x000000|80|0xffffff|0x0099ff|0x000000"> 
  <item item_url="/site/images/1.jpg" link="http://*****vote.do?method=list&id=7" id="1" titleName="aa"/>  
  <item item_url="/site/images/2.jpg" link="http://***/" id="2"  titleName="bb"/>  
  <item item_url="/site/images/3.jpg" link="http://***" id="3"  titleName="bb"/>
</bcaster>

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(java,apache,xml,Web,struts)