문제

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