我正在使用 spring jdbc 模板进行 CRUD。插入、选择和删除操作工作正常,但我在更新过程中遇到了以下异常。
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.lang.Integer]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.lang.Integer.<init>()
这是我的控制器:
@RequestMapping(value="/editCompany/{companyId}", method= RequestMethod.GET)
public String edit(@PathVariable(value="companyId")Integer companyId,ModelMap map) {
Company company=companyService.get(companyId);
map.addAttribute("company", company);
map.put("companyId", companyId);
return "editCompany";
}
@RequestMapping(value="/editCompany/{companyId}", method= RequestMethod.POST)
public String save(@ModelAttribute("company")Integer companyId,Company company,BindingResult result, ModelMap map) {
companyValidator.validate(company, result);
if (result.hasErrors()) {
return "editCompany";
} else {
Integer i=companyService.save(company);
return "status";
}
}
我也@Autowired
为控制器使用了注释。如何解决?任何形式的帮助表示赞赏。