afunms

          My Software,My Dream—Forge a more perfect NMS product.

          new framework(8)--import static

          現在J2SE 5.0提供了靜態導入的功能,你只需要在import關鍵字后面寫一個static關鍵字就可以直接
          使用類中定義的常量了,例如

          import static afu.framework.util.Constant.CURRENT_USER;
          import static afu.framework.util.Constant.EXCEPTION_MESSAGE;

              public String login()
              
          {
                  String userId 
          = getParaValue("userid");
                  String password 
          = getParaValue("password");
                  String remoteIp 
          = request.getRemoteAddr();
                  UserDto dto 
          = ((SysService)service).login(userId, password, remoteIp);
                  
                  
          if(dto==null)
                  
          {
                      request.setAttribute(EXCEPTION_MESSAGE,
          "用戶名或密碼不對");
                      
          return null;
                  }

                  request.setAttribute(CURRENT_USER,dto);
                  
          return "/common/index.jsp";
              }


          而沒有這個功能之前,我們得這么寫
          request.setAttribute(Constant.EXCEPTION_MESSAGE,"用戶名或密碼不對");

          posted on 2007-05-08 10:40 afunms 閱讀(114) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 兰西县| 清远市| 宁南县| 桐庐县| 东乡县| 岢岚县| 道孚县| 渭南市| 巴彦淖尔市| 枝江市| 黔江区| 太保市| 乌拉特前旗| 辉县市| 云和县| 荆门市| 平阴县| 鄱阳县| 牙克石市| 蚌埠市| 威宁| 大足县| 嘉善县| 密云县| 宁远县| 松阳县| 汉中市| 惠安县| 嵩明县| 崇明县| 温泉县| 鹤山市| 高清| 罗山县| 泾川县| 诏安县| 西充县| 东城区| 大连市| 遂川县| 遂溪县|