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=""/>,如下:
错误方式:
- <mvc:interceptors>
- <!-- 局部拦截器 -->
- <mvc:interceptor>
- <mvc:exclude-mapping path="/user_login" />
- <mvc:exclude-mapping path="/user_logout" />
- <mvc:mapping path="/**" />
- <bean class="com.itcast.oa.interceptor.MyInterceptor" />
- </mvc:interceptor>
- </mvc:interceptors>
- <mvc:interceptors>
- <!-- 局部拦截器 -->
- <mvc:interceptor>
- <mvc:mapping path="/**" />
- <mvc:exclude-mapping path="/user_login" />
- <mvc:exclude-mapping path="/user_logout" />
- <bean class="com.itcast.oa.interceptor.MyInterceptor" />
- </mvc:interceptor>
- </mvc:interceptors>