0
votes

By using spring interceptor i want to intercept all request except some so i want to exclude it. i got the solution by using mvc:exclude-mapping but it shows error.

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        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/util http://www.springframework.org/schema/util/spring-util-3.0.xsd ">


    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
        up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="test.org.reg" />

    <mvc:interceptors>
        <beans:bean
            class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <beans:property name="paramName" value="lang" />
        </beans:bean>


<mvc:interceptor>
          <!--   <mvc:mapping path="/" /> -->
            <mvc:mapping path="/**" />
            ***<mvc:exclude-mapping path="/test/**" />***
             <beans:bean class="a.b.c.MyInterceptor"></beans:bean> 
        </mvc:interceptor>
</mvc:interceptors>
    <beans:bean
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
        id="multipartResolver" />
    <beans:import resource="classpath:DI/*.xml" />


</beans:beans>

here in mvc:exclude mapping tag throws error i.e

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, "http://www.springframework.org/schema/beans":bean}' is expected.

1

1 Answers

0
votes

Make sure the xsd points to 3.2.

xsi:schemaLocation="springframework.org/schema/beans springframework.org/schema/beans/spring-beans-3.2.xsd springframework.org/schema/context springframework.org/schema/context/spring-context-3.2.xsd springframework.org/schema/mvc springframework.org/schema/mvc/spring-mvc-3.2.xsd">

Spring added that feature since Spring 3.2. Here is the link to the doc.