ability to have multiple path patterns per mapped interceptor definition

This commit is contained in:
Keith Donald
2009-11-30 07:51:29 +00:00
parent d4a21f1db8
commit c8d6360855
8 changed files with 92 additions and 64 deletions

View File

@@ -35,7 +35,6 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.style.StylerUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
@@ -49,7 +48,6 @@ import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.ModelAndView;
@@ -170,6 +168,11 @@ public class MvcNamespaceTests {
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[3] instanceof WebRequestHandlerInterceptorAdapter);
request.setRequestURI("/foo/logged");
chain = mapping.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[3] instanceof WebRequestHandlerInterceptorAdapter);
}
@Test

View File

@@ -9,10 +9,10 @@
<mvc:annotation-driven />
<mvc:interceptors>
<mvc:interceptor class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang" />
<mvc:interceptor class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang" />
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
<property name="paramName" value="style" />
</mvc:interceptor>
</bean>
</mvc:interceptors>
</beans>

View File

@@ -8,9 +8,16 @@
<mvc:annotation-driven />
<mvc:interceptors>
<mvc:interceptor class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<mvc:interceptor path="/**" class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
<mvc:interceptor path="/logged/**" class="org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor" />
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<mvc:interceptor>
<mvc:path value="/**" />
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:path value="/logged/**" />
<mvc:path value="/foo/logged" />
<bean class="org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>

View File

@@ -12,8 +12,8 @@
<mvc:view-controller path="/bar" view-name="baz" />
<mvc:interceptors>
<mvc:interceptor class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<mvc:interceptor class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
</mvc:interceptors>
</beans>