解决方案 »

  1.   


      String s =  Util.getHttpResult("http://172.18.1.171:8016/Service.gkean", "get", "service_name=system.attachments.GetCheckCode&sid="+pcSid+"&maxTimeout="+300, "utf-8");
    其实我就要用HTTPclient实现上面的代码,顺便上传个文件
      

  2.   

      HttpClient httpClient = new HttpClient();
                        PostMethod postMethod = new PostMethod("http://172.18.1.171:8016/Service.gkean");
                        FilePart fp = new FilePart("file", file);
                        Part[] parts = { fp };
                        //对于MIME类型的请求,httpclient建议全用MulitPartRequestEntity进行包装
                        MultipartRequestEntity mre = new MultipartRequestEntity(parts, postMethod.getParams());
                        postMethod.setRequestEntity(mre);
                        postMethod.addParameter("service_name","system.attachments.Upload");
                        postMethod.addParameter("sid",sid);
                        postMethod.addParameter("checkCode",checkCode);
                        postMethod.addParameter("savePath","/userSite");
                        httpClient.executeMethod(postMethod);
                        String str1="";
                        str1=new String(postMethod.getResponseBodyAsString().getBytes("utf-8"));
                        System.out.println(str1);
                        postMethod.releaseConnection();
    我是这么写的.但是初始化postMethod的时候直接就跳到finally里面了,.都没报错