cvc-complex-type.2.4.a: Invalid content was found starting with element 'mvc:exclude-mapping'. One of '{"http://www.springframework.org/schema/mvc":mapping}' is expected.

 

在配置springmvc拦截器的时候,一直报上面的错误,刚开始以为是xsd文件或版本不匹配,后来网上找了一下,原来是要先配置<mvc:mapping path=""/> ,再配置<mvc:exclude-mapping path=""/>,如下:

错误方式:

 

 
  1. <mvc:interceptors>  
  2.     <!-- 局部拦截器 -->  
  3.     <mvc:interceptor>                   
  4.         <mvc:exclude-mapping path="/user_login" />  
  5.         <mvc:exclude-mapping path="/user_logout" />  
  6.         <mvc:mapping path="/**" />  
  7.         <bean class="com.itcast.oa.interceptor.MyInterceptor" />  
  8.     </mvc:interceptor>  
  9. </mvc:interceptors>  
 
更改之后的:

 

 
  1. <mvc:interceptors>  
  2.     <!-- 局部拦截器 -->  
  3.     <mvc:interceptor>  
  4.         <mvc:mapping path="/**" />                      
  5.         <mvc:exclude-mapping path="/user_login" />  
  6.         <mvc:exclude-mapping path="/user_logout" />  
  7.         <bean class="com.itcast.oa.interceptor.MyInterceptor" />  
  8.     </mvc:interceptor>  
  9. </mvc:interceptors>  
 
由此,问题得到解决。