I have a generic error page which is not decorated by SiteMesh.
May I know what is the reason ?
<filter>
<display-name>SiteMesh_Filter</display-name>
<filter-name>SiteMesh_Filter</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SiteMesh_Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<error-code>404</error-code>
<location>/pages/error.jsp</location>
</error-page>
Thanks.
This is the most recent archive of the original issue.
This is the closed issue page.
So, it looks like you need to make sure that you're not using a release that's more than 2 years old :), and you need to make sure that your SiteMesh filter is configured to process error pages by including:
along with whatever else you need...
I'm going to assume you're using Sitemesh 3 as a decorator. Your configuration in the questions tells me you're using Sitemesh 2, but you mentioned using Sitemesh 3 in the comment to @kschneid answer.
Sitemesh 3 uses a
Selector
implementation to select which requests it can buffer (decorate). By default this is theorg.sitemesh.webapp.contentfilter.BasicSelector
. This selector has two constructors namely:The former is used by the
BaseSiteMeshFilterBuilder
to construct the selector by default. This means theincludeErrorPages
property will be set tofalse
and only pages with a status of 200 OK will be buffered by the filter. To overcome this you will need to somehow use the other constructor and setincludeErrorPages
totrue
.This can be done by subclassing
org.sitemesh.config.ConfigurableSiteMeshFilter
and override the protectedapplyCustomConfiguration(SiteMeshFilterBuilder builder)
method ending up with a method similar to:The above will instruct the builder to use the custom selector which now will decorate error pages. The only thing left is to add a instance of
ErrorPageEnabledSiteMeshFilter
to yourServletContext
replacing the old one.