I have object that have attributes id, name, description.
In some case i want to return whole object but in some i want to return only id, suppose when I insert new record it should only return id that is newly generated.
public class DTO { private Integer id; private String name; private String description; // getter-setter } controller:
@RequestMapping(value = "/{cname}/met", method = RequestMethod.POST) @ResponseBody public DTO addMet(@PathVariable String cname, @RequestBody DTO met) { return service.addMet(met); // service return whole DTO object that is newly added with new Id } I want to return only id as response, so any help or guidance on it that how to do so ?
Thank you.
addMetcannot returnIntegerinstead ofDTO?Jsonlike{id:'1'}, if i ll return it as integer it will just give meidin response.