SPR-6996 Add mvc:interceptor bean references
This commit is contained in:
@@ -179,7 +179,7 @@ public class MvcNamespaceTests {
|
||||
|
||||
@Test
|
||||
public void testInterceptors() throws Exception {
|
||||
loadBeanDefinitions("mvc-config-interceptors.xml", 14);
|
||||
loadBeanDefinitions("mvc-config-interceptors.xml", 16);
|
||||
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
@@ -191,20 +191,21 @@ public class MvcNamespaceTests {
|
||||
request.addParameter("theme", "green");
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertEquals(3, chain.getInterceptors().length);
|
||||
assertEquals(4, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
|
||||
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
|
||||
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
|
||||
assertTrue(chain.getInterceptors()[2] instanceof WebRequestHandlerInterceptorAdapter);
|
||||
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
|
||||
|
||||
request.setRequestURI("/logged/accounts/12345");
|
||||
chain = mapping.getHandler(request);
|
||||
assertEquals(4, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[3] instanceof WebRequestHandlerInterceptorAdapter);
|
||||
assertEquals(5, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);
|
||||
|
||||
request.setRequestURI("/foo/logged");
|
||||
chain = mapping.getHandler(request);
|
||||
assertEquals(4, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[3] instanceof WebRequestHandlerInterceptorAdapter);
|
||||
assertEquals(5, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||
|
||||
<mvc:annotation-driven />
|
||||
|
||||
<mvc:interceptors>
|
||||
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
|
||||
<ref bean="log4jInterceptor"/>
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/**" />
|
||||
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
|
||||
@@ -16,8 +17,11 @@
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/logged/**" />
|
||||
<mvc:mapping path="/foo/logged" />
|
||||
<bean class="org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor" />
|
||||
<ref bean="log4jInterceptor"/>
|
||||
</mvc:interceptor>
|
||||
</mvc:interceptors>
|
||||
|
||||
|
||||
<bean id="log4jInterceptor"
|
||||
class="org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor" />
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user