zoukankan      html  css  js  c++  java
  • struct2访问或添加request/session/application

    访问或添加request/session/application
    1 通过ActionContext
    //这样放置
    public String execute()
     {
        ActionContext ctx = ActionContext.getContext();
        ctx.getApplication().put("app","lll");
        ctx.getSession().put("ses","session范围");
        ctx.put("req", "request范围");
        return "success";
     }
    //这样取出
     <body> 
       ${applicationScope.app}<br>
       ${sessionScope.ses}<br>
       ${requestScope.req}<br>
     </body>


    2 获取相应对象

    2.1 通过ServletActionContext类直接获取:
    public String rsa() throws Exception{
     HttpServletRequest request = SerletActionContext.getRequest();
     request.setAttribute("req","请求范围属性");
     request.getSession().setAttribute("res","会话属性");
    }

    2.2实现指定接口,由struct2框架运行时注入
    public class HelloWorldAction implements ServletRequestAware,ServletResponseAware,ServletContextAware
    {
      private HttpServletRequest request;
      public void setServletRequest(HttpServletRequest req){
         this.request = res;
      }
    }

  • 相关阅读:
    c++ bitset 10进制转二进制
    PIVOT
    西渡
    check all tables rows

    View Triggers Function Procedure
    ORA-01400: cannot insert NULL into
    中东
    力的合成
    正弦、余弦和正切
  • 原文地址:https://www.cnblogs.com/sandea/p/3520769.html
Copyright © 2011-2022 走看看