sitemesh3 not decorating error pages #25

Closed
atomi opened this Issue Mar 30, 2011 · 5 comments

Comments

Projects
None yet
4 participants

atomi commented Mar 30, 2011

if you set an error-page element in web.xml sitemesh3 won't decorate that file.

ERROR in the filter-mapping does nothing.
Hopefully someone can confirm this as well - just in case I might have missed something.

atomi commented Apr 12, 2011

Just wanted to follow up on this issue.
The following is working for me.

<filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>ERROR</dispatcher>
        <dispatcher>FORWARD</dispatcher>
</filter-mapping>

My earlier problem with errors not being decorated was just a user error (If dispatcher>REQUEST is added it will not work).
Thanks.

atomi closed this Apr 12, 2011

pasemes commented Aug 7, 2014

atomi definition worked for me...

m4wayne commented Jul 16, 2015

遇到同样的问题,help

flopma commented Apr 25, 2017

Hi,

I cannot confirm this work. Actually, the ERROR dispatcher is needed because in my case Tomcat 8.0.43 will handle error page with a ERROR dispatcher (for error pages defined in the web.xml).

But when we arrive into org.sitemesh.webapp.contentfilter.BasicSelector.filterAlreadyAppliedForRequest(HttpServletRequest) from org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ServletRequest, ServletResponse, FilterChain), the method will return true because the request has already been through the SiteMesh filter. This will make SiteMesh filter to skip decoration of the error page.

So I don't get how this can work. For the me bug is still there.

Can someone confirm or invalidate?

Thx

flopma commented Apr 26, 2017

I had to create a new selector extending the BasicSelector and override this method so SiteMesh would work nicely with Spring Security and Spring MVC since I did not put Sitemesh as the first Filter, I prefer Spring Security filters to be the 1st.

    @Override
    protected boolean filterAlreadyAppliedForRequest(HttpServletRequest request) {
      if (request.getDispatcherType().equals(DispatcherType.ERROR)) {
        LOG.debug("Currently in a ERROR dispatcher - preventing SiteMesh from skipping decoration");
        return false;
      }

      return super.filterAlreadyAppliedForRequest(request);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment