【问题标题】:@RequestParam remove question mark in URL@RequestParam 删除 URL 中的问号
【发布时间】:2015-05-06 09:21:48
【问题描述】:

我正在尝试使用 Spring 构建 REST API。

如何替换 URI

localhost: 8080 / rest / api / v1 / users / id ?id = 1

localhost: 8080 / rest / api / v1 / users / id / 1

【问题讨论】:

    标签: spring api rest


    【解决方案1】:

    我使用@PathVariable 成功解决了这个问题,例如:

    public ResponseEntity<String> hello (@PathVariable Integer id) {
    
            String hello  ="hello "+ id ;
            return new ResponseEntity<String>(hello, HttpStatus.ACCEPTED);
        }
    

    对应的网址是:

    localhost:8080/hello/15
    

    Tkx

    【讨论】:

      猜你喜欢
      • 2012-11-27
      • 2015-06-25
      • 1970-01-01
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 2013-09-04
      • 2016-01-09
      • 1970-01-01
      相关资源
      最近更新 更多