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?
One solution is to code the search form as plain HTML in your JSP/template, so that you remove any dependency on the form binding object. For a simple search form with a text input and submit button, this should not be a problem.