是否有任何为struts2操作类提供的init方法,可以在该操作类的每个方法之前调用?是否有任何给struts2动作类的init方法?
例如,我有支柱2的操作类下面
import com.opensymphony.xwork2.ActionSupport;
public class EmployeeAction extends ActionSupport{
private DepartmentDaoService deptService = new DepartmentDaoService() ;
private EmployeeDaoService empService = new EmployeeDaoService();
private Employee employee;
private List<Employee> employees;
private List<Department> departments;
public void init()
{
//Do initialization stuff here
}
public String getAllEmployees(){
employees = empService.getAllEmployees();
return "success";
}
public String deleteEmployee(){
empService.deleteEmployee(employee.getEmployeeId());
return "success";
}
}
现在,在上面的代码中给出当用于getAllEmployees撑杆动作()和deleteEmplyee()被调用我想init()方法来执行第一。我们可以通过从两个函数中调用它来运行它。
但是,在struts 2中是否有任何规定会在每次调用时自动运行init方法,或者struts 2为动作类提供任何此类方法?
请告诉我,如果有人知道。
谢谢。
谢谢rdk。 这是非常有用的信息。 – amar4kintu 2009-05-30 04:39:31