JAVA

          人生若只如初見,何事秋風悲畫扇。

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            50 隨筆 :: 25 文章 :: 157 評論 :: 0 Trackbacks
          ?URLConnection?urlconn? = ?targeturl.openConnection();
          ????????????urlconn?
          = ?targeturl.openConnection();
          ????????????urlconn.setRequestProperty(
          " Content-Type " ,? " application/x-www-form-urlencoded " );
          ????????????urlconn.setRequestProperty(
          " method " ,? " post " );
          ????????????urlconn.setDoOutput(
          true );
          ????????????DataOutputStream?dos?
          = ? new ?DataOutputStream(urlconn.getOutputStream());
          ????????????OutputStreamWriter?output?
          = ? null ;
          ????????????output?
          = ? new ?OutputStreamWriter(dos);
          ????????????output.write(Query);
          ????????????output.flush();
          ????????????dos.close();
          ????????????output.close();
          ????????????urlconn.getInputStream();

            今天上午在這段代碼里面,有個地方讓我郁悶了。對了targeturl的值是指向了一個actinon(struts相關)。而此action是extends DispatchAction。
          到了urlconn.getInputStream();中,顯然要觸發urlconn。也就是上面的action了。然后不懂的是它竟然觸發了此action中的update方法,郁悶ing...中。為什么偏偏觸發它呢?原來,update方法是由unspecified所引用,

          ??public?ActionForward?unspecified(ActionMapping?mapping,?ActionForm?form,
          ????????????HttpServletRequest?request,?HttpServletResponse?response)?
          {
          ????????
          return?update(mapping,?form,?request,?response);
          ????}

            而上述代碼中顯示沒有指定method,so it will acive the default method(unspecified) which defined in struts .In struts it defined in org.apache.struts.actions.DispatchAction .

            
          that is why the codes active the update method !
            if you see the problem in another style , it will be bring another effect to u !
          posted on 2006-05-11 12:30 Jkallen 閱讀(1821) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 砚山县| 历史| 玉溪市| 辽宁省| 白河县| 景德镇市| 应城市| 宝应县| 绵阳市| 双柏县| 泾阳县| 出国| 连云港市| 望城县| 洪江市| 剑阁县| 桃园县| 城固县| 溆浦县| 泗阳县| 武强县| 新宾| 白水县| 莱阳市| 宝坻区| 珠海市| 奉新县| 阜新| 东至县| 南江县| 广西| 全南县| 都江堰市| 昌吉市| 巴林右旗| 滨海县| 武夷山市| 河南省| 江门市| 阜康市| 吴忠市|