问题
Now I have code like this:
@RestController
public class ChildController {
@RequestMapping(value = "/parents/{parentId}/addChild", method = RequestMethod.POST)
public void addChild(@RequestBody ChildDTO child, @PathVariable Long parentId) {
child.setParentId(parentId);
//...
}
}
class ChildDTO {
private Long parentId;
private String name;
private double weight;
private double height;
//setters ang getters
}
Is there any way to map parentId in child object without calling setter in method body? I need it for my Aspect @Before logic
来源:https://stackoverflow.com/questions/39728571/spring-map-field-of-requestbody-with-pathvariable