【问题标题】:@PathVariable and @RequestMapping issues@PathVariable 和 @RequestMapping 问题
【发布时间】:2011-08-14 03:43:48
【问题描述】:

我只想通过 dispatcher-servlet 发送以 .html 结尾的请求,而所有其他请求都直接处理,所以我已将其映射到 web.xml..

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

但问题是我将无法使用@pathvariable 功能,其中 url 看起来像“show/{id}”.. 此请求未映射,因为它不包含“.html”最后春天不会照顾它..我知道的唯一方法是将url模式更改为“person.html?id = 12313”并使用控制器中的@RequestParam获取该ID......所以我想要知道是否有任何方法在这里使用@PathVariable 方法,同时保持servlet-mapping 到.html 仅..

【问题讨论】:

    标签: spring-mvc path-variables


    【解决方案1】:

    PathVariable放到网址中间,如下:/person/{id}/show.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 2020-02-17
      • 2018-07-11
      • 1970-01-01
      • 2014-03-15
      • 2011-01-21
      相关资源
      最近更新 更多