當你新建了一個SSM項目,你復制網上的xml文件來配置或者你下載了一個SSM項目打開發現xml文件錯誤,打開是第一行報錯的時候你是不是很懵逼

或者是這樣

總之就是xml文件中<?xml version="1.0" encoding="UTF-8"?>報錯該怎么辦呢。解決方法
核對清楚你要的xmlns先,然后去網上找其他的springMVC.xml的配置,然后復制到你的文件上保存,看還報錯不,如果發生了標頭以下內容報錯了,那說明你少了那個標頭聲明,你所以你要核對清楚你要的聲明。
比如

則發生

所以如果你復制了網上的表頭聲明發生原本沒錯的內容錯誤,則考慮你需要的一下表頭聲明缺失了。
下面提供一些我的可以正確使用的xml標頭聲明
比如適用於applicationContext.xml的表頭聲明
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
適用於springmvc.xml的標頭聲明
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
">
以上
希望能幫到
