我的问题是如何调用它。我可以
MyObject o = new MyObject();
myController.save(o, "value");
但这不是我想做的。我希望 MyObject 在请求帖子正文中吗?如何才能做到这一点?
@Requestmapping(value="/save/{value}", method=RequestMethod.POST)
public void post(@Valid MyObject o, @PathVariable String value{
objectService.save(o);
}
为了清楚起见,我说的是单元测试。
编辑:
@RequestMapping(value = "/", method = RequestMethod.POST)
public View postUser(ModelMap data, @Valid Profile profile, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return dummyDataView;
}
data.put(DummyDataView.DATA_TO_SEND, "users/user-1.json");
profileService.save(profile);
return dummyDataView;
}