@RequestMapping(value = "/getjson", method = RequestMethod.GET, produces="application/json")@ResponseBodypublic String getJson() { //your logic ObjectMapper mapper = new ObjectMapper(); return mapper.writevalueAsString(json);}@RequestMapping(value = "/post", method = RequestMethod.POST, produces="application/json", consumes="application/json")@ResponseBodypublic String post(@RequestBody String json) { POJO pj = new POJO(); ObjectMapper mapper = new ObjectMapper(); pj = mapper.readValue(json, POJO.class); //do some things with json, put some header information in json return mapper.writevalueAsString(pj);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)