struts2获取request、session、application
public class LoginAction extends ActionSupport implements RequestAware,SessionAware, ApplicationAware { private Map<String, Object> request;
private Map<String, Object> session;
private Map<String, Object> application; public String execute() {
request.put("r1", "r1");
session.put("s1", "s1");
application.put("a1", "a1");
return SUCCESS;
} @Override
public void setRequest(Map<String, Object> request) {
this.request = request;
} @Override
public void setSession(Map<String, Object> session) {
this.session = session;
} @Override
public void setApplication(Map<String, Object> application) {
this.application = application;
}
}
jsp页面获取request/session/application中的值
<s:property value="#request.r1"/> | <%=request.getAttribute("r1") %> <br />
<s:property value="#session.s1"/> | <%=session.getAttribute("s1") %> <br />
<s:property value="#application.a1"/> | <%=application.getAttribute("a1") %> <br />