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 阅读(1799) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: