使用java应用程序提交表单
2009-12-18 21:11:03 来源:WEB开发网核心提示:URL url = new URL(urlString);URLConnection connection = url.openConnection();connection.setDoOutput(true);PRintWriter out = new PrintWriter(connection.getOutput
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
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
更多精彩
赞助商链接