Results 1 to 2 of 2

Thread: Spring MVC Http 404

  1. #1

    Default Spring MVC Http 404

    Hi,

    I use Spring MVC and it works fine, if I enter a html- name which has no mapping I get the message:

    No mapping found for HTTP request with URI ...

    My question would be what can I do in order to redirect to an error page.
    I read about NoSuchRequestHandlingMethodException but I don't knowhow to use (http://static.springsource.org/sprin.../html/mvc.html)

    It would be very kind if someone could explain me how to use.
    Thanks a lot and all the best.
    Generic1

  2. #2

    Default

    No I have tried this:

    Code:
    public class DispatcherServletHandler extends DispatcherServlet {
    
        /**
         if a url (servlet name) is entered in Browser which does not exist, than redirect to an error page
         */
        @Override
        protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception {
           System.out.println("Class DispatcherServletHandler, method noHandlerFound: " + request.getRequestURL() + ", User will be redirected to default page index.htm");
           RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("./index.htm");
           dispatcher.forward(request,response);
        }
    }

    It works but I only can redirect to the index.htm page (this is the default page) but I can't redirect to an error page.
    Does anyone know what I am doing wrong?

    Thanks a lot!
    Generic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •