I've got following class
@Configuration
public class WebConfiguration {
@Bean
public ServletRegistrationBean slspServlet() {
ServletRegistrationBean testServlet = new ServletRegistrationBean(new TestServlet());
testServlet.addUrlMappings("/*");
testServlet.setAsyncSupported(true);
return TestServlet;
}
@Bean
public ServletRegistrationBean aliveServlet() {
ServletRegistrationBean aliveServlet = new ServletRegistrationBean(new AliveServlet());
aliveServlet.addUrlMappings("/alive/*");
aliveServlet.setLoadOnStartup(3);
return aliveServlet;
}
@Bean
public ServletRegistrationBean templateDownloaderServlet(){
ServletRegistrationBean templateDownloader = new ServletRegistrationBean(new TemplateDownloaderServlet());
templateDownloader.addUrlMappings("/template/download/*");
templateDownloader.setLoadOnStartup(2);
return templateDownloader;
}
@Bean
public ServletRegistrationBean endOfGenerationThreadServlet(){
ServletRegistrationBean endOfGenerationThread = new ServletRegistrationBean(new EndOfGenerationThreadServlet());
endOfGenerationThread.addUrlMappings("/endofgenerationthread/*");
endOfGenerationThread.setLoadOnStartup(1);
return endOfGenerationThread;
}
@Bean
public ServletRegistrationBean dispatcherServlet(){
ServletRegistrationBean dispatcherServlet = new ServletRegistrationBean(new DispatcherServlet());
dispatcherServlet.setName("dispatcherServlet");
dispatcherServlet.addUrlMappings("/dispatcher/*");
return dispatcherServlet;
}
@Bean
public FilterRegistrationBean errorPageFilter(){
FilterRegistrationBean errorPageFilter = new FilterRegistrationBean(new ErrorPageFilter(), dispatcherServlet());
errorPageFilter.addUrlPatterns("/test/*");
return errorPageFilter;
}
@Bean
public FilterRegistrationBean characterEncodingFilter(){
FilterRegistrationBean characterEncodingFilter = new FilterRegistrationBean(new CharacterEncodingFilter(), dispatcherServlet());
characterEncodingFilter.addUrlPatterns("/test/*");
return characterEncodingFilter;
}
@Bean
public FilterRegistrationBean hiddenHttpMethodFilter(){
FilterRegistrationBean hiddenHttpMethodFilter = new FilterRegistrationBean(new HiddenHttpMethodFilter(), dispatcherServlet());
hiddenHttpMethodFilter.addUrlPatterns("/test/*");
return hiddenHttpMethodFilter;
}
}
What am I trying to do is change filter mapping of hiddenHttpMethodFilter, characterEncodingFilter, errorPageFilter so for that I have mapping /test/*. When I start application I can see that it defaults to "/*"
Mapping servlet: 'testServlet' to [/*]
Mapping servlet: 'aliveServlet' to [/alive/*]
Mapping servlet: 'templateDownloaderServlet' to [/template/download/*]
Mapping servlet: 'endOfGenerationThreadServlet' to [/endofgenerationthread/*]
Mapping servlet: 'dispatcherServlet' to [/dispatcher/*]
Mapping filter: 'errorPageFilter' to: [/*]
Mapping filter: 'characterEncodingFilter' to: [/*]
Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
What am I missing or what's wrong with my config? I'm on spring-boot 1.2.5.
There is another problem with filters (I think that's in filters). When I want to access request.getInputstream()
in my testServlet it's already read. I also read this question and tried to implement RequestWrapper, but it's too late in my testServlet to wrap the request, because inputstream was read. So can somebody help me how to resolve this?
Thanks