I would like to send only the requests ending in .html through dispatcher-servlet and all other requests handled directly, so I have mapped that in web.xml..

  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>

but the problem is then that I won't be able to use @pathvariable feature where the url looks something like "show/{id}".. this request is not mapped because this doesn't contain ".html" at the end spring won't take care of it.. Only way that I know is to change the url pattern to "person.html?id=12313" and get that id using @RequestParam in the controller... So I want to know if there is anyway to use @PathVariable method here while keeping the servlet-mapping to .html only..

有帮助吗?

解决方案

Put the PathVariable into the middle of the URL, as follows: /person/{id}/show.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top