Skip to content

Instantly share code, notes, and snippets.

@nblair
Created April 21, 2016 13:21
Show Gist options
  • Save nblair/fd8de42958c53ef4dfcfa2073e2ea1a2 to your computer and use it in GitHub Desktop.
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/)
@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