您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

内容类型为application / x-www-form-urlencoded的Http Post请求在Spring中不起作用

内容类型为application / x-www-form-urlencoded的Http Post请求在Spring中不起作用

问题在于,当我们使用application / x-www-form-urlencoded时,Spring不会将其理解为RequestBody。因此,如果要使用它,则必须删除@RequestBody批注。

然后尝试以下操作:

@RequestMapping(value = "/patientdetails", method = RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public @ResponseBody List<PatientProfileDto> getPatientDetails(
        PatientProfileDto name) {


    List<PatientProfileDto> list = new ArrayList<PatientProfileDto>();
    list = service.getPatient(name);
    return list;
}
Java 2022/1/1 18:24:53 有589人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶