JavaEE笔记(七)

Struts获取如何获取请求响应和回话

//获取HttpServletRequest
HttpServletRequest request = ServletActionContext.getRequest();
//获取HttpServletResponse
HttpServletResponse response= ServletActionContext.getResponse();
//获取session回话
HttpSession session = request.getSession();

Struts封装的请求回话
//首先获取ActionContext 
ActionContext actionContext = ActionContext.getContext()
//请求级以map的形式存放数据
actionContext.put(key,value);
//获取map类型的session
Map<String, Object> session = actionContext.getSession();
//回话级以map的形式存放数据
session.put(key,value);

 

posted @ 2016-12-05 00:48  dawn-tangzedong  阅读(146)  评论(0编辑  收藏  举报