Add exclude patterns for mapped interceptors

Add the ability provide exclude patterns for mapped interceptors in the
MVC namespace and in the MVC Java config.

Issue: SPR-6570
This commit is contained in:
Rossen Stoyanchev
2012-07-20 14:28:17 -04:00
parent 5a365074c2
commit 92759ed1f8
10 changed files with 236 additions and 84 deletions

View File

@@ -4453,7 +4453,8 @@ public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LocalInterceptor());
registry.addInterceptor(new LocaleInterceptor());
registry.addInterceptor(new ThemeInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**");
registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*");
}
@@ -4463,6 +4464,11 @@ public class WebConfig extends WebMvcConfigurerAdapter {
<programlisting language="xml">&lt;mvc:interceptors&gt;
&lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /&gt;
&lt;mvc:interceptor&gt;
&lt;mapping path="/**"/&gt;
&lt;exclude-mapping path="/admin/**"/&gt;
&lt;bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" /&gt;
&lt;/mvc:interceptor&gt;
&lt;mvc:interceptor&gt;
&lt;mapping path="/secure/*"/&gt;
&lt;bean class="org.example.SecurityInterceptor" /&gt;