Struts2_API

Posted rocker-pg

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Struts2_API相关的知识,希望对你有一定的参考价值。

1.访问servletAPI方法1


 

  

 1 public String execute() throws Exception {
 2         //request域对象==》map (struts2并不推荐使用原生request域对象)
 3         //不推荐
 4         Map<String, Object> requestScope = (Map<String, Object>) ActionContext.getContext().get("request");
 5         //推荐
 6         ActionContext.getContext().put("name", "requestTom");
 7         //session域对象==》map
 8         Map<String, Object> sessionScope = ActionContext.getContext().getSession();
 9         sessionScope.put("name", "sessionTom");
10         //application域对象==》map
11         Map<String, Object> applicationScope = ActionContext.getContext().getApplication();
12         applicationScope.put("name", "applicationTom");
13         return SUCCESS;
14     }

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

以上是关于Struts2_API的主要内容,如果未能解决你的问题,请参考以下文章