我有这堂课:
PreApprovalRequest 类具有headings
在控制器中自动填充的属性(请参阅页面下方的控制器代码)。
public class PreApprovalRequest {
private Long id;
private String Description;
private Collection<Headings> headings; //this property!
}
和控制器:
@Controller
@SessionAttributes({"preApprovalRequest", "productRecommendations"})
public class RequestController {
@RequestMapping(value = "/submit", method = RequestMethod.POST)
public String submitResults(@ModelAttribute(value = "preApprovalRequest") @Valid PreApprovalRequest preApprovalRequest, BindingResult errors) {
//HERE: It looks like if I have some headings in the preApprovalRequest object already, the call of this method will not delete those, but will append to the existing list.
//save object in DB.
return "dashboard";
}
}
知道如何让 Spring 替换集合对象而不是添加到它吗?