我正在以这种方式实施PUT
@RequestMapping(method = RequestMethod.PUT, value = ServicesDictionary.API_DOMAIN_DEMAND + "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK, reason = "Update successful")
@ResponseBody
@Override
@LogMe("MarketDemandService.PUT.update")
public jsonObject update(@RequestBody @Valid MongoMarketDemand marketDemand, @PathVariable String id) {
//do update
return jsonObject
}
但是当我看到ResponseEntity时,我看到body是null。我怎样才能返回一个json对象?
答案 0 :(得分:0)
在实体正文中返回一些内容......您可以使用@ResponseBody
public @ResponseBody MongoMarketDemand update(@RequestBody @Valid MongoMarketDemand marketDemand, @PathVariable String id) {
...
MongoMarketDemand updatedMarketDemand = ...
return updatedMarketDemand;
}