sitemesh / sitemesh3

SiteMesh 3: Official repository
https://sitemesh.github.io/sitemesh-website/
Apache License 2.0
480 stars 168 forks source link

JSP error page is not decorated #116

Closed pioterj closed 1 year ago

pioterj commented 7 years ago

Default JSP error page is not decorated by SiteMesh 3 in Spring Boot app despite includeErrorPages being set to true.

Steps to reproduce

Sample project

Full project: sitemesh-issue.zip

Spring configuration class (also provided in the attached sample project):

@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {

    @Bean
    public InternalResourceViewResolver setupViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/jsp/");
        resolver.setSuffix(".jsp");
        resolver.setViewClass(JstlView.class);
        return resolver;
    }

    @Bean
    public FilterRegistrationBean siteMeshFilter() {
        FilterRegistrationBean filter = new FilterRegistrationBean();
        Filter siteMeshFilter = new SiteMeshFilterBuilder()
            .addDecoratorPath("/*", "/WEB-INF/jsp/decorator.jsp")
            .setIncludeErrorPages(true)
            .create();
        filter.setFilter(siteMeshFilter);
        filter.setUrlPatterns(Arrays.asList("/*"));
        // filter.setDispatcherTypes(ERROR); // with this error page is decorated but not other pages
        // filter.setDispatcherTypes(REQUEST, FORWARD, ERROR); // this doesn't work either
        return filter;
    }
}
pioterj commented 7 years ago

I just found this comment: https://github.com/sitemesh/sitemesh3/issues/25#issuecomment-991330. It works after adding filter.setDispatcherTypes(ERROR, FORWARD);

codeconsole commented 1 year ago

Works as intended.