转载请注明出处 csdn wankaiming
public class InstanceInterceptor implements Interceptor{
private IStudentDAO isd;
private IQuestionDAO iqd;
public InstanceInterceptor() {
// TODO Auto-generated constructor stub
}
public void destroy() {
isd = null;
iqd = null;
}
public void init() {
isd = new StudentDAOImpl();
iqd = new QuestionDAOImpl();
}
public String intercept(ActionInvocation arg0) throws Exception {
ActionContext ac=arg0.getInvocationContext();
HttpServletRequest request=(HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
request.setAttribute("studentdao", isd);
request.setAttribute("questiondao", iqd);
return arg0.invoke();
}
}