首页 > 学院 > 开发设计 > 正文

使用java应用程序提交表单

2019-11-17 03:57:09
字体:
来源:转载
供稿:网友
URL url = new URL(urlString);
      URLConnection connection = url.openConnection();
      connection.setDoOutput(true);

      PRintWriter out = new PrintWriter(connection.getOutputStream());

      boolean first = true;
      for (Map.Entry<String, String> pair : nameValuePairs.entrySet())
      {
         if (first) first = false;
         else out.print('&');
         String name = pair.getKey();
         String value = pair.getValue();
         System.out.println(name);
         System.out.println(value);
         out.print(name);
         out.print('=');
         out.print(URLEncoder.encode(value, "UTF-8"));
      }

      out.close();



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/helloxtayfnje/archive/2009/12/17/5026608.aspx
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表