大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 EL表達式取值的范圍

EL表達式取值的范圍

更新時間:2020-08-24 11:10:50 來源:動力節點 瀏覽1451次


有些朋友對于EL表達式取值的范圍不是很了解,在Struts2中對request進行了裝飾,增強了getAttribute()方法,改變了EL該方法的查找范圍,具體為,查找request域,不存在,查找值棧,不存在,查找ContextMap,還是不存在,則返回null。


EL表達式取值


因為${對象名},會使用findAttribute的查找,其順序是page域->request域->session域->application域原理如下:


public class PageContext{


   //在page域中根據name獲取value
   public Object getAttribute(String name){
      return "找到了返回對象" | "沒找到返回null";
   }
   
   //從四個域中逐個搜索,只要在其中一個找到,就不再繼續尋找
   public Object findAttribute(String name){
      Object value = null;
      //搜page域
      value = this.getAttribute(name);
      if(value != null){
         return value;
      }
      //搜request域
      value = this.getRequest().getAttribute(name);
      if(value != null){return value;}//搜session域value = this.getSession().getAttribute(name);if(value != null){return value;}//搜application域value = this.getServletContext().getAttribute(name);if(value != null){return value;}return value;}}


PS:由上述原因,Struts2對request進行了裝飾,那么訪問順序變為page域->request域->值棧->ContextMap->session->application。


如果還想深究源碼,可以參考ServletConfigInterceptor攔截器


public class ServletConfigInterceptor extends AbstractInterceptor implements StrutsStatics {
   private static final long serialVersionUID = 605261777858676638L;
   public String intercept(ActionInvocation invocation) throws Exception {
       final Object action = invocation.getAction();
       final ActionContext context = invocation.getInvocationContext();

       if (action instanceof ServletRequestAware) {
           HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
           ((ServletRequestAware) action).setServletRequest(request);
       }

       if (action instanceof ServletResponseAware) {
           HttpServletResponse response = (HttpServletResponse) context.get(HTTP_RESPONSE);
           ((ServletResponseAware) action).setServletResponse(response);
       }

       if (action instanceof ParameterAware) {
           ((ParameterAware) action).setParameters((Map)context.getParameters());
       }

       if (action instanceof ApplicationAware) {
           ((ApplicationAware) action).setApplication(context.getApplication());
       }

       if (action instanceof SessionAware) {
           ((SessionAware) action).setSession(context.getSession());
       }

       if (action instanceof RequestAware) {
           ((RequestAware) action).setRequest((Map) context.get("request"));
       }

       if (action instanceof PrincipalAware) {
           HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
           if(request != null) {
              // We are in servtlet environment, so principal information resides in HttpServletRequest
              ((PrincipalAware) action).setPrincipalProxy(new ServletPrincipalProxy(request));
           }
       }
       if (action instanceof ServletContextAware) {
           ServletContext servletContext = (ServletContext) context.get(SERVLET_CONTEXT);
           ((ServletContextAware) action).setServletContext(servletContext);
       }
       return invocation.invoke();
   }
}


以上就是動力節點java培訓機構的小編針對“EL表達式取值的范圍”的內容進行的回答,希望對大家有所幫助,如有疑問,請在線咨詢,有專業老師隨時為你服務。


提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 成人人观看的免费毛片 | 嫩模被xxxx视频在线观看 | 亚洲国产成人久久精品动漫 | 国产一区二区成人 | 特级一级毛片视频免费观看 | 亚洲国产欧美在线不卡中文 | 四虎永久在线日韩精品观看 | 亚洲系列在线 | 亚洲综合激情六月婷婷在线观看 | 中国欧美日韩一区二区三区 | 91热久久免费精品99 | 日本深夜影院 | 一级特黄aaa大片在线观看 | 特黄特黄aaaa级毛片免费看 | 亚洲国产一区二区三区在线观看 | 青青青爽国产在线视频 | 四虎在线永久免费观看 | 黄色天堂在线 | 欧美一级成人影院免费的 | 国产精品久久久久无毒 | 午夜私人影院粉色视频我要 | 婷婷在线成人免费观看搜索 | 久久久精品国产免费观看同学 | 国产精品久久久久尤物 | 中文字幕福利视频 | 日韩精品一区二区三区中文在线 | 久久国产这里只精品免费 | 99热这里只有精品在线播放 | 日韩中文字幕精品视频在线 | 伊人久久丁香色婷婷啪啪 | 欧美日韩生活片 | 日本中文字幕网站 | 国产swag在线 | 亚洲日日夜夜 | 免费四虎永久在线精品 | 色婷婷综合久久久 | 天天射天天干天天色 | 国产综合精品久久久久成人影 | 天天操夜夜爽 | 久久精品啪啪嗷嗷叫 | 精品在线播放视频 |