不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

框架整合 的时候,XML配置文件大多数情况是从另一个框架里面复制的。

今天在练习整合的时候明明之前的项目对着,但是复制到这个项目后就报错。

错误代码:

<span style="color:#FF0000;">严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from file [D:\java\File\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SpringMVC1\WEB-INF\classes\config\spring-common.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 7; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。  </span>
不允许有匹配 "[xX][mM][lL]" 的处理指令目标。说明XML可能不规范,哪里有些出入? 于是我就Ctrl+Shift+F 格式化了一下代码,然后缩进对齐。 再次部署,没有报错。上网查了下,说是这种异常是XML没有以<?xml version="1.0" encoding="UTF-8"?> 开头,也就是说第一个字符必须是<?xml......


解决方法:

 规范的XML格式、

 <?xml version="1.0" encoding="UTF-8"?>  必须是XML文件的第一个元素且前面不能空格。

猜你喜欢

转载自ximeng1234.iteye.com/blog/2205725