弹簧。使用@PathVariable映射@RequestBody的字段

时间:2016-09-27 15:25:36

标签: java spring mapping

现在我有这样的代码:

@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
}

有没有办法在子对象中映射parentId而不在方法体中调用setter? 我需要它为我的Aspect @Before逻辑

0 个答案:

没有答案