How to debug Spring MVC url mapping?

For problems like this I feel like the best “entrypoint” to start debugging is the method getHandler(HttpServletRequest request) of the DispatcherServlet.

Inside this method every configured HandlerMapping is inspected if it responsible for handling your specific request. If your request makes it this far, you can be quite sure that it is a configuration problem inside the spring context.

Watch out for handlers of the type RequestMappingHandlerMapping (or DefaultAnnotationHandlerMapping, if you are using an older version of Spring), these are normally the HandlerMapping used by annotation based Controller configuration.

In the other case, make sure there is nothing “in front” of the DispatcherServlet filtering your requests (like in your case)

Leave a Comment