【问题标题】:@RequestParam in GET is always null when it's called using HTTPs使用 HTTPs 调用 GET 中的 @RequestParam 始终为空
【发布时间】:2019-09-27 04:01:59
【问题描述】:

我现在有这个方法:

 @RequestMapping(path = "/api2/rep/report_payment_grouped/{startDate}/{endDate}", method = RequestMethod.GET)
    public @ResponseBody
    ResponseEntity getPaymentsGroupedReport(HttpServletRequest request,
                                        @PathVariable String startDate,
                                        @PathVariable String endDate,
                                        @RequestParam(required = false, value = "requestId") Integer requestId) {

这会返回一个对象报告,其中包含两个列表,fieldsDefs,数据,以及在原始请求中收到的 requestId:

    return ResponseEntity
            .ok(new Report(fieldDefs, data, requestId));

这是客户端返回的对象(正确):

在网络数据中:

现在,当服务部署在我的 AWS 服务器中时,请求完全相同,requestId 始终为空:

这是回复:

我已尝试手动设置 requestId serverSide 并在这种情况下正确返回值。因此确认 requestId 参数被接收为 null/empty。

【问题讨论】:

  • 尝试通过request.getParameter("requestId");获取参数或显示代码如何在客户端传递参数。
  • 你能提供新报告构造函数的代码吗?
  • 这个“AWS 服务器”是 EC2 机器吗?您是直接访问它,还是通过 CloudFront 等其他 AWS 服务?
  • 请描述您的浏览器和应用程序之间的关系。你用的是什么http代理,有什么负载均衡器,有zuul或者其他api网关吗?

标签: java spring-boot spring-mvc


【解决方案1】:

我怀疑您在 AWS 上的服务无法访问数据库。你看过错误日志吗?

【讨论】:

  • 信息在那里。 data 和 fieldDefs 有正确的信息。只是 requestId 正在接收 null。
  • 你在requestId上有什么注释?
猜你喜欢
  • 2018-12-27
  • 2017-05-12
  • 1970-01-01
  • 2018-12-18
  • 2016-01-01
  • 2012-02-04
  • 2019-11-04
  • 2014-08-06
  • 2011-06-09
相关资源
最近更新 更多