org.springframework.web.util.NestedServletException:请求处理失败 [英] org.springframework.web.util.NestedServletException: Request processing failed
本文介绍了org.springframework.web.util.NestedServletException:请求处理失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用spring jdbc模板进行CRUD. 插入,选择和删除操作运行正常,但是在更新过程中出现了以下异常情况.
I am doing CRUD using spring jdbc template. insert,select and delete operations are working fine but I got these following exception in update process.
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
注释.
怎么解决呢?任何帮助都将受到赞赏.
I have used @Autowired
annotation for the controller too.
How to resolve it? any kind of help is appreciated.
推荐答案
我将Post方法更改为following,并且有效.
I changed my Post method to following and it worked.
public String save(@ModelAttribute("company")Company company,BindingResult result, ModelMap map)
这篇关于org.springframework.web.util.NestedServletException:请求处理失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文