In my web.xml page I have the 404 error mapped to a jsp page as:
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/errorPages/error404.jsp</location>
</error-page>
The redirect on 404 works fine. I get to error404.jsp. The problem is that I have a spring form on the page (a search form that is on EVERY page) which causes errors because the target object is not in the model. I get the following exception:
Caused by: java.lang.IllegalStateException: Neither BindingResult nor
plain target object for bean name ‘searchCriteria’ available as request attribute
I’d like to have this search form on every page, including the error pages. Is there any way to do this? I realize that 404 as I have it configured above doesn’t go to a servlet… so how do I get the request attribute into the model?
The way to do this is to map the error pages to a servlet. Within the servlet you can add things to your model just like you can in any other servlet. To map error pages to a servlet, add something like the following to your web.xml file:
where “error” is the servlet name and “generalError” is the request mapping.