I have a spring-based web application. In a controller I specified the following:
@RequestMapping(value = "/foo/index.html", method = RequestMethod.GET)
public ModelAndView handleIndex(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("public/foo/index");
}
The application web.xml servlet mapping:
<servlet-mapping>
<servlet-name>jib</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
When I make a request to the http://myhost/foo/index.hml everything works fine, but when I am trying to invoke http://myhost/foo/ – I receive a 404 error.
My question is how I can handle http://myhost/foo/ request exactly how I handle the http://myhost/foo/index.html request?
Ok, the solution is shown below
Change the servlet-mapping section in the web.xml file
Change the @RequestMapping value parameter:
Now, the handleIndex method handles all requests for /foo/ and /foo/index.html paths
Hope it will help somebody