在控制器中,您可以这样做:
@RequestMapping(value = "/create", method = RequestMethod.POST) public ModelAndView create(@ModelAttribute Policy p) { if (p.getAdjusterId().getEntityId() == null) { p.setAdjusterId(null); } policyService.create(p); return new ModelAndView("viewName"); }