sitemesh3: Java based configuration not working
Hello,
I tried the java-based configuration but it doesn’t work.
I created a custom filter as in the example on the website and registered it in my Spring MVC application according to the code below.
JAKARTA EE 17 SITEMESH 3.2.0-M2 SPRING FRAMEWORK 6.0.12 APACHE TOMCAT 10.1.13 ECLIPSE 2023-09 (4.29.0)
//custom filter public class MySiteMeshFilter extends ConfigurableSiteMeshFilter { @Override protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) { builder.addDecoratorPath("/*", "/decorator.html") .addDecoratorPath("/admin/*", "/admin/decorator.html"); } }
`public class AppConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] {SpringConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
// TODO Auto-generated method stub
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] {"/"};
}
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
return new Filter[]{ characterEncodingFilter, new CustomSitemeshFilter() }; //HERE
}
}`
If I register the custom filter using web.xml, works.
<filter> <filter-name>sitemesh</filter-name> <filter-class>com.myapp.filter.MySiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
EDIT 1:
With Java based config I can set a breakpoint and debug my CustomSitemeshFilter class, but the decorator is not applied.
Thank you very much in advance.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (13 by maintainers)
@xkguq007 you want to give the latest snapshot a try?
I separated it here: https://github.com/sitemesh/sitemesh3/commit/7b01ebb46833f0531a1626428b155f6d0d498d56
@xkguq007 3.2.1 and 3.1.1 have both just been released to maven central.
Ok, we will look into repackaging. You can expect a new release in a week timeframe.
hello @xkguq007, I need some more time to look into this, but I will get it working for you.
@xkguq007 I will do an official release after you confirm it working