public class WebAction extends ActionSupport {
private HttpServletRequest req;
private Map<String, Object> session;
private ServletContext application;
private HttpServletResponse resp;
@Override
public String execute() throws Exception {
resp=ServletActionContext.getResponse()
req = ServletActionContext.getRequest();
session = ServletActionContext.getContext().getSession();
application = ServletActionContext.getServletContext();
req.setAttribute("req", "req_str");
session.put("session", "session_str");
application.setAttribute("app", "app_str");
return SUCCESS;
}
}
获取struts2中的对象 方式request、session、application、 resp
最新推荐文章于 2024-11-01 14:48:20 发布