gistfile1.txt public class DepartmentAction extends ActionSupport implements ModelDriven {//模型驱动需要使用的对象private Department department = new Department();public Department getModel() {return department;}//Spring注入部门
public class DepartmentAction extends ActionSupport implements ModelDriven{ //模型驱动需要使用的对象 private Department department = new Department(); public Department getModel() { return department; } //Spring注入部门管理的Service private DepartmentService DepartmentService; public void setDepartmentService(DepartmentService DepartmentService) { this.DepartmentService = DepartmentService; } //通过action返回添加的视图的jsp public String saveUI(){ return "saveUI"; } //添加部门的save方法 public String saveInfo(){ DepartmentService.save(department); return "saveSuccess"; } public String delete(){ Department dep = DepartmentService.editById(department.getDid()); DepartmentService.delete(dep); return "deleteSuccess"; } }