BorderJ's Blog

          --- java FreeBsd Web3D open-sources

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            8 隨筆 :: 1 文章 :: 40 評(píng)論 :: 0 Trackbacks
          HttpRequest對(duì)象有兩種形式的getSession方法調(diào)用:
          一個(gè)是getSession(),
          另一個(gè)是getSession(boolean isNew)

          這樣的,前者會(huì)檢測(cè)當(dāng)前時(shí)候有session存在,如果不存在則創(chuàng)建一個(gè),如果存在就返回當(dāng)前的。
          getSession()相當(dāng)于getSession(true),

          參數(shù)為true時(shí),若存在會(huì)話(huà)則返回該會(huì)話(huà),否則新建一個(gè)會(huì)話(huà)。
          參數(shù)為false時(shí),若存在會(huì)話(huà)則返回該會(huì)話(huà),否則應(yīng)該返回一個(gè)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的提醒,現(xiàn)在已經(jīng)修正。
          Edit By: BorderJ??? 2006.8.18


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

          評(píng)論

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

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

          謝謝提醒,

          現(xiàn)在已經(jīng)更正。  回復(fù)  更多評(píng)論
            

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

          主站蜘蛛池模板: 益阳市| 和平县| 扬中市| 信丰县| 土默特右旗| 三明市| 霸州市| 柏乡县| 繁峙县| 阜平县| 璧山县| 双峰县| 广元市| 利辛县| 江阴市| 靖州| 定边县| 罗平县| 大洼县| 常熟市| 北碚区| 铜陵市| 丁青县| 农安县| 黑水县| 赤城县| 耒阳市| 万全县| 平阴县| 祥云县| 安徽省| 泸水县| 大宁县| 新巴尔虎左旗| 尼玛县| 周至县| 灵武市| 大兴区| 板桥市| 黄龙县| 岳阳县|