I want to provide a custom 404 error page in my Spring 3.1 web application, but I cannot deactivate Jetty 8's default 404 error page.
Jetty 8, out of the box, provides a default 404 error page:
when visiting a Jetty-hosted website, and providing a URL path that is not handled by any servlet (e.g. by visiting http://www.example.com/nonexisting ), Jetty responses with its own default HTML error page:
HTTP ERROR 404
Problem accessing /nonexisting. Reason:
Not Found
Powered by Jetty://
To replace this default behavior,
- I've removed the
DefaultHandlerfrom my Jetty XML file, - I've edited my
web.xmlto include both Servlet 2.5 and Servlet 3.0 error handler locations pointing to/error, - I've set up a dedicated
@Controllerfor handling the request to/error,
but my website still returns Jetty's own default HTML error page.
Jetty 8's official documentation talks about setting up a "custom error pages", but the suggestions there say
- to configure a custom Jetty error handler (I don't want to do this, I want to do it inside my own Spring
@Controlleras mentioned above) - to create a "catch all context and create a "root" web app mapped to the
/URI." (I don't want to do this as inside myweb.xmlI have already mapped Spring MVC'sDispatcherServletto /.
How can I turn off Jetty's default error handler and have the error handling be done as pointed out above?