I am using spring 3.0.5 MVC and trying to defined LoginInterceptor
for specified path /fx
. I looked up and found the way to use is:
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<mvc:interceptor>
<mapping path="/fx"/>
<bean class="com.fxiapi.auth.LoginInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
I want to use this for any page other than Login page for certain URI. Is their a way to ignore login page URI. Also, using this was I am getting following exception:
2011-02-07 11:04:22,756 ERROR http-0.0.0.0-8680-1 Context initialization failed org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 31 in XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'mapping'. One of '{"http://www.springframework.org/schema/mvc":mapping}' is expected. at org.springframework.beans.factory.xml.XmlBeanDefinitio开发者_JAVA技巧nReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
Can someone please help? Whats the alternate if I cant use tag?
The error message tells you what's wrong - you need the namespace prefix on the <mapping>
element also:
<mvc:interceptor>
<mvc:mapping path="/fx"/>
...
</mvc:interceptor>
精彩评论