BorderJ's Blog

          --- java FreeBsd Web3D open-sources

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            8 隨筆 :: 1 文章 :: 40 評論 :: 0 Trackbacks
          HttpRequest對象有兩種形式的getSession方法調用:
          一個是getSession(),
          另一個是getSession(boolean isNew)

          這樣的,前者會檢測當前時候有session存在,如果不存在則創建一個,如果存在就返回當前的。
          getSession()相當于getSession(true),

          參數為true時,若存在會話則返回該會話,否則新建一個會話。
          參數為false時,若存在會話則返回該會話,否則應該返回一個NULL

          這是文檔:

          getSession ?
          ? public ? HttpSession ? getSession(boolean ? create)Returns ? the ? current ? HttpSession ? associated ? with ? this ? request ? or, ? if ? if ? there ? is ? no ? current ? session ? and ? create ? is ? true, ? returns ? a ? new ? session. ? ?
          ? If ? create ? is ? false ? and ? the ? request ? has ? no ? valid ? HttpSession, ? this ? method ? returns ? null. ? ?
          ? ?
          ? To ? make ? sure ? the ? session ? is ? properly ? maintained, ? you ? must ? call ? this ? method ? before ? the ? response ? is ? committed. ? If ? the ? container ? is ? using ? cookies ? to ? maintain ? session ? integrity ? and ? is ? asked ? to ? create ? a ? new ? session ? when ? the ? response ? is ? committed, ? an ? IllegalStateException ? is ? thrown. ?
          ? ?
          ? Parameters: ?
          ? true ? - ? to ? create ? a ? new ? session ? for ? this ? request ? if ? necessary; ? false ? to ? return ? null ? if ? there's ? no ? current ? session ?
          ? Returns: ?
          ? the ? HttpSession ? associated ? with ? this ? request ? or ? null ? if ? create ? is ? false ? and ? the ? request ? has ? no ? valid ? session ?


          感謝
          zhouhu的提醒,現在已經修正。
          Edit By: BorderJ??? 2006.8.18


          posted on 2006-07-31 19:46 BorderJ 閱讀(7865) 評論(3)  編輯  收藏 所屬分類: Java

          評論

          # re: request.getSession() 方法 2006-08-18 11:45 zhouhu
          getSession()相當于getSession(true),  回復  更多評論
            

          # re: request.getSession() 方法 2006-08-18 13:08 BorderJ

          謝謝提醒,

          現在已經更正。  回復  更多評論
            

          # re: request.getSession() 方法 2007-03-19 19:13 小神
          ok  回復  更多評論
            

          主站蜘蛛池模板: 龙胜| 宁陵县| 雷波县| 砚山县| 钦州市| 贡觉县| 五家渠市| 旅游| 福州市| 射阳县| 浦江县| 广德县| 蛟河市| 比如县| 西华县| 聊城市| 靖宇县| 兴隆县| 玉林市| 闻喜县| 永丰县| 贵阳市| 庄河市| 邹平县| 永善县| 海淀区| 晋中市| 永定县| 商水县| 石首市| 北流市| 丰顺县| 雅安市| 红河县| 万山特区| 兴山县| 齐河县| 普兰店市| 鸡西市| 莫力| 石阡县|