My problem starts when I want to access to an url with this pattern ignoring any extension
localhost:8084/project/foo/1
I got this web.xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/foo</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
Actually, to access to that url, I need to use /foo/1.html and I want to use /foo/1, because I will use that number as id to find an object and I don't know if I'm missing something, but this config doesnt work.
Controller code
@Controller
public class FooController {
@RequestMapping(value = "/foo/{id}")
public ModelAndView telefono(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @PathVariable String id) {
Map<String, Object> model = new HashMap<String, Object>();
// Code to search foo
return new ModelAndView("foo", model);
}
}