Struts2_API

1.访问servletAPI方法1


  

 public String execute() throws Exception {
//request域对象==》map (struts2并不推荐使用原生request域对象)
//不推荐
Map<String, Object> requestScope = (Map<String, Object>) ActionContext.getContext().get("request");
//推荐
ActionContext.getContext().put("name", "requestTom");
//session域对象==》map
Map<String, Object> sessionScope = ActionContext.getContext().getSession();
sessionScope.put("name", "sessionTom");
//application域对象==》map
Map<String, Object> applicationScope = ActionContext.getContext().getApplication();
applicationScope.put("name", "applicationTom");
return SUCCESS;
}

request:${requestScope.name}<br> session:${sessionScope.name}<br> application:${applicationScope.name}<br>

上一篇:迷你版jQuery——zepto核心源码分析


下一篇:小兴趣:修改Hosts文件,禁止访问指定网页