Created
April 21, 2016 13:21
-
-
Save nblair/fd8de42958c53ef4dfcfa2073e2ea1a2 to your computer and use it in GitHub Desktop.
Spring @configuration for registering an instance of UrlRewriteFilter (see http://tuckey.org/urlrewrite/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class UrlRewriteFilterConfiguration { | |
/** | |
* Registers a {@link UrlRewriteFilter}. | |
* Set the init-param on the filter to use slf4j for logging. | |
* | |
* Configuration goes in src/main/resources/urlrewrite.xml (root of the classpath). | |
* | |
* @return a {@link FilterRegistrationBean} wrapping a {@link UrlRewriteFilter} | |
*/ | |
@Bean | |
public FilterRegistrationBean filter() { | |
FilterRegistrationBean filter = new FilterRegistrationBean(); | |
filter.setFilter(new UrlRewriteFilter()); | |
filter.setInitParameters(ImmutableMap.<String,String>builder() | |
.put("logLevel", "slf4j") | |
.put("confPath", "urlrewrite.xml") | |
.build()); | |
return filter; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment