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();

posted on 2013-02-28 09:51  专注2018  阅读(2690)  评论(0编辑  收藏  举报