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);
上一篇:前后端分离之JWT用户认证(转)


下一篇:network FAQ