【问题标题】:Spring: rest webservice callSpring:休息网络服务调用
【发布时间】:2016-05-24 23:38:09
【问题描述】:

我正在尝试在我的 customerDoaImpl 文件的服务 url 中附加我的查询,但它没有返回正确的值。我尝试在服务端使用soapUI进行测试,但它正在向我的请求返回正确的数据。

我正在尝试根据 productId 和 datePeriod 搜索结果 这是我的代码 sn-p-

  url.append(getServiceUrl()).append( "/transaction/find/customerrequestv2?id={productId}&dateperiod={Dateperiod}");

服务端控制器-

    @RequestMapping(value = "/find/customerrequestv2", method = RequestMethod.GET,produces = "application/json")

  public List<Customer> CustomerRequestv2(@RequestParam(value = "id") final String pProductId,
  @RequestParam(value = "dateperiod") final String pDateperiod)

我在查询中做错了什么?

【问题讨论】:

  • 确保对查询字符串进行编码。

标签: spring web-services rest spring-mvc spring-data


【解决方案1】:

占位符{productId}{Dateperiod} 实际上必须用真正的字符串替换,否则它将被逐字发送到服务器。例如使用字符串格式:

String url = String.format("/transaction/find/customerrequestv2?id=%s&dateperiod=%s", productId, datePeriod);

【讨论】:

  • 感谢先生您的快速回答.. 欣赏它.. :)
  • 如果答案回答了您的问题,您应该投票并接受它。
猜你喜欢
  • 1970-01-01
  • 2012-07-20
  • 2011-11-08
  • 2015-12-24
  • 2018-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-02
相关资源
最近更新 更多