我的数据格式是:data [model] [field] 因此,在控制层中,我正在处理我的欲望类的对象并将对象传递给服务层。现在我想把(@Valid Designation desg)放在服务层功能中。但它没有用。
控制器:
@RequestMapping(value = "/Designation/save", method = RequestMethod.POST)
public @ResponseBody Object saveDesignation(@PathVariable String role, @ModelAttribute Designation desg, BindingResult result,
HttpServletRequest request, HttpServletResponse response) {
desg.setName(request.getParameter("data[designation][name]"));
return desgService.insert(desg, result, request, role, Designation.class);
}
服务层:
public Object insert(@Valid Designation desg, BindingResult result, String role, Class clazz) {
...............
}
servlet.xml中:
<mvc:annotation-driven/>
<context:component-scan base-package="net.divineIt.titas.controllers" />
<context:component-scan base-package="net.divineIt.titas.services" />
任何帮助将不胜感激。 TIA