问题在于,当我们使用 application / x-www-form-urlenpred时
,Spring不会将其理解为RequestBody。因此,如果要使用它,则必须删除 @RequestBody 批注。
然后尝试以下操作:
@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = {MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})public @ResponseBody Representation authenticate(@PathVariable("email") String anEmailAddress, MultiValueMap paramMap) throws Exception { if(paramMap == null && paramMap.get("password") == null) { throw new IllegalArgumentException("Password not provided"); } return null;}请注意,删除了注释 @RequestBody



