从用户获取参数并在post方法中使用它

时间:2018-05-16 13:39:22

标签: php spring spring-boot post get

@RequestMapping(value="/thyroidReport",method = { RequestMethod.GET, RequestMethod.POST }, produces = "application/JSON")
   public ArrayList<thyroidMedicalReport> getThyroidDetails(@RequestParam("id") String personId) throws IOException{
      return thyroidReportHandler.getDetails(personId);
   }

以上代码是以JSON格式发布甲状腺报告详细信息。但是,我需要从我的网站(PHP代码)中获取用户ID,这也需要GET方法以及ID的请求。

POST调用应采用以下格式:     http://localhost:8090/thyroidReport?id=123

我收到以下编译错误:

The method getDetails(String) in the type thyroidReportHandler is not applicable for the arguments 

1 个答案:

答案 0 :(得分:0)

如果您的服务thyroidReportHandler有效,您可以这样做:

   @RequestMapping(value="/thyroidReport", method = RequestMethod.GET)
   public ArrayList<thyroidMedicalReport>getThyroidDetails(@RequestParam(value="id") String personId) throws IOException{
      return thyroidReportHandler.getDetails(personId);
   }

您不需要执行两次HTTP呼叫,您可以在GET中提供所有信息。

顺便说一句,我会让你的班级thyroidMedicalReport以大写字母开头!