I'm using spring boot, and I would like to use sitemesh3 to my project. I need to add the sitemesh filter, I create this class :
@Configuration
public class Initializer implements ServletContextInitializer{
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
//Sitemesh
FilterRegistration.Dynamic sitemesh = servletContext.addFilter("sitemesh", new ConfigurableSiteMeshFilter());
EnumSet<DispatcherType> sitemeshDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
sitemesh.addMappingForUrlPatterns(sitemeshDispatcherTypes, true, "*.jsp");
}
}
I created the file sitemesh3.xml
in WEB-INF directory but nothing happened, have I missed some configuration?
ServletContextInitializer
s aren't picked up with Spring Boot. Add the filter to your application configuration and wrap it in a FilterRegistrationBean
.
See the Spring Boot reference guide.