配置文件报错:不允许有匹配 "[xX][mM][lL]" 的处理指令目标

原帖子地址

http://blog.csdn.net/niubaofeng2011/article/details/39007693


错误代码:

  1. <span style="color:#FF0000;">严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener  
  2. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:   
  3. 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;   
  4. nested exception is org.xml.sax.SAXParseException;   
  5. lineNumber: 1; columnNumber: 7; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。  
  6.  </span>  

  1. 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。说明XML可能不规范,哪里有些出入?  
  2.   
  3. 于是我就Ctrl+Shift+F 格式化了一下代码,然后缩进对齐。  
  4.   
  5. 再次部署,没有报错。上网查了下,说是这种异常是XML没有以<?xml version="1.0" encoding="UTF-8"?> 开头,也就是说第一个字符必须是<?xml......  


解决方法:

 规范的XML格式、

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

猜你喜欢

转载自blog.csdn.net/ningfuxuan/article/details/77127059