配置request、session
public class BaseAction extends ActionSupport implements ServletRequestAware,
ServletResponseAware {
public HttpSession session;
public ServletContext application;
protected HttpServletRequest request;
protected HttpServletResponse response;
public void setServletRequest(HttpServletRequest request) {
this.request = request;
this.session = request.getSession();
this.application = session.getServletContext();
}
public void setServletResponse(HttpServletResponse response) {
this.response = response;
}
public ServletContext getApplication() {
return application;
}
public void setApplication(ServletContext application) {
this.application = application;
}
public void setSession(HttpSession session) {
this.session = session;
}
protected String getParama(String paramaName){
return this.request.getParameter(paramaName);
}
protected String[] getParamas(String paramaName) {
return this.request.getParameterValues(paramaName);
}
protected Object getSessionAttri(String name) {
return this.session.getAttribute(name);
}
protected Object getRequestAttri(String name) {
return this.request.getAttribute(name);
}
}
ServletResponseAware {
public HttpSession session;
public ServletContext application;
protected HttpServletRequest request;
protected HttpServletResponse response;
public void setServletRequest(HttpServletRequest request) {
this.request = request;
this.session = request.getSession();
this.application = session.getServletContext();
}
public void setServletResponse(HttpServletResponse response) {
this.response = response;
}
public ServletContext getApplication() {
return application;
}
public void setApplication(ServletContext application) {
this.application = application;
}
public void setSession(HttpSession session) {
this.session = session;
}
protected String getParama(String paramaName){
return this.request.getParameter(paramaName);
}
protected String[] getParamas(String paramaName) {
return this.request.getParameterValues(paramaName);
}
protected Object getSessionAttri(String name) {
return this.session.getAttribute(name);
}
protected Object getRequestAttri(String name) {
return this.request.getAttribute(name);
}
}