Following is my controller
@RestController
@RequestMapping("identity/v1/")
public class InvestigateTargetController {
@RequestMapping(method = RequestMethod.POST, value = "receive",
produces = OneplatformMediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<InvestigateOutputResource>
processRequest(@RequestBody JSONObject jsonObject) {
System.out.println(jsonObject.toString());
return new ResponseEntity<>(HttpStatus.OK);
}
}
I am trying to send a json object to this controller via POSTMAN. But when I print jsonObject.toString()
the output is {}
( empty ). Following are snapshots of POSTMAN:
Where am I going wrong ?
创建一个具有与json对象相同的属性(带有getter和setter)的Java类,并将其作为requestbody。
Solved it. Instead of JSONObject
catch it in a string type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.