Article View: cn.bbs.comp.lang.java
Article #12140����HttpURLConnection POST��ʽ���ӵ�����
From: CS^00^
Date: Thu, 05 Aug 2004 10:03
Date: Thu, 05 Aug 2004 10:03
40 lines
2311 bytes
2311 bytes
��֪����ȷ�ķ�ʽ��Σ��������δ��뾿���ĸ����أ����Ƕ����أ�
ţ����������
String u="http://localhost:8080/jsp/search.jsp?tsmc=data";
URL url = new URL(u);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");//ֻ����һ��Ϳ�����
//����Ϊ�����Ӧ��Ϣ
BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStrea
m(),"GB2312"));
String line;
while ((line = rd.readLine()) != null)
{
out.println(line);
}
��������һ�ַ�ʽ
String u="http://localhost:8080/jsp/search.jsp";
String data="tsmc=data";
URL url = new URL(u);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");//��һ����Ҫ�𣿣�
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputSt
ream());
wr.write(data);
wr.flush();
//ʣ�µIJ��ֺ͵�һ�ַ�����ͬ
���ڵ������ǵ�һ�ַ���ֻ����������ʽΪpost��ʽ�Ϳ�����
����һ�ַ�����������ʽҲ��Ҫ��
֪���Ļظ�һ�°ɣ�3x
--
�ٺ٣������Ź���ƶ����Ҹ����
[m[1;31m�� ��Դ:������δ��վ bbs.pku.edu.cn��[FROM: 162.105.71.140][m
Technical Details
Message-ID:
<4DVJkO$ASJ@bbs.pku.edu.cn>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!nntp-server.pubsub.com!maily.cic.tsinghua.edu.cn!news.happynet.org!PKUShow Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,348cd800c7f102b0,start X-Google-Attributes: gidf6cb0,public X-Google-Language: Chinese,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!nntp-server.pubsub.com!maily.cic.tsinghua.edu.cn!news.happynet.org!PKU From: tianlanlan@bbs.pku.edu.cn (CS^00^@����Ϲ�ת�ͣ��ٺ�) Newsgroups: cn.bbs.comp.lang.java Subject: ����HttpURLConnection POST��ʽ���ӵ����� Date: 05 Aug 2004 10:03:56 GMT Organization: ����δ��վ Message-ID: <4DVJkO$ASJ@bbs.pku.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: Java/M.1091699640.A Lines: 40