在DepartmentAction中有 new Department,为什么在department edit 方法中会出现department为空指针异常。
public String edit(){
Integer id =Integer.parseInt(org.apache.struts2.ServletActionContext.getRequest().getParameter("id"));
department = departmentService.findById(id);
return "editSuccess";
}
把获取id值得方法修改一下
试试能不能解决问题,注意粗体字
//驱动模型
private Department department ;
@Override
public Department getModel() {
return department;
}
改为:
private Department department = new Department() ;
@Override
public Department getModel() {
return department;
}
http://blog.csdn.net/li_tengfei/article/details/6098145 这篇文章应该能解决你的问题
有可能是department没有正常接收到页面传来的数据吧!