Assuming you have Spring's TilesViewResolver
and TilesConfigurer
configured, you can try the following bean definition:
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Throwable">error</prop>
</props>
</property>
</bean>
And then simply define the logical view error
:
<definition name="error" extends="common">
<put-attribute name="body" value="/WEB-INF/jsp/error.jsp"/>
</definition>
This will forward any Throwable
to the right view, where you have access to the exception itself (${exception}
). This doesn't replace all standard HTTP error pages (for 404 etc.)