PDA

View Full Version : Page not found from HandlerExceptionResolver


nickcodefresh
Sep 12th, 2006, 11:55 AM
Does anyone know how to return a 404 'page not found' message from the resolveException() method of a HandlerExceptionResolver subclass? I can use the following, but what do I return as the ModelAndView?

response.sendError(HttpServletResponse.SC_NOT_FOUN D);


Thanks

Nick

Mark Fisher
Sep 12th, 2006, 01:19 PM
For a generic "page-not-found", you probably just want to configure that as normal in a web.xml mapping. Is there something else that you want to have available in the view that would require using the exception resolver?

nickcodefresh
Sep 12th, 2006, 03:18 PM
Basically I want to show a page not found if a request parameter doesn't exist in the database. Therefore the page exists (blah.htm) but the whole request is invalid. I can trap the failure of the DB lookup and throw an exception, but then I want to show whatever 404 page the server is configured for.