[英]Spring MVC: Request Mapping for JSONObject in Request body
import org.json.JSONObject;
@RequestMapping(value = "/uploadMultipleFile", method = RequestMethod.POST,consumes = "application/json")
public @ResponseBody void uploadMultipleFileHandler(@RequestBody JSONObject validationData,HttpServletRequest request, HttpServletResponse response) {
System.out.println(validationData);
}
I am unable to map this request form Postman. 我无法映射此请求表邮递员。 Its giving me error : description The request sent by the client was syntactically incorrect.
它给我错误: description The request sent by the client was syntactically incorrect.
But if I change the JSONObject to String then its working form POSTMAN. 但是,如果我将JSONObject更改为String,则其工作形式为POSTMAN。
Have you tried that ? 你尝试过吗?
Use @RequestBody Map<String, Object> validationData
instead of @RequestBody JSONObject validationData. 使用@RequestBody Map<String, Object> validationData
代替@RequestBody JSONObjectvalidationData。
Hope this will help you. 希望这会帮助你。
public void getValues(@RequestBody Map<String, Object> validationData, final HttpServletRequest request, final HttpServletResponse response) {
System.out.println(pvmValues.get("key"));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.