java中使用request,application,session,cookie对象
导入包:
import javax.servlet.ServletContext;
import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext; import org.apache.struts2.interceptor.CookiesAware;
类中声明:
private Map<String, String> cookie;
public ServletContext application = ServletActionContext.getServletContext();
public HttpServletRequest request = ServletActionContext.getRequest();
public HttpServletResponse response = ServletActionContext.getResponse();
public HttpSession session = request.getSession();
国泰民安