public class Test { public Test() throws HttpException, IOException {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("127.0.0.1",80,"http");
PostMethod post = new PostMethod("/index.html");
NameValuePair name = new NameValuePair("username","sdaf");
post.setRequestBody(new NameValuePair[]{name});
int t = client.executeMethod(post);
System.out.println(t); //输出 200
post.releaseConnection();
GetMethod get = new GetMethod("/ok.asp");
client.executeMethod(get);
System.out.println(get.getResponseBodyAsString()); //这里没输出
get.releaseConnection();
} public static void main(String[] args) throws HttpException, IOException {
new Test();
}}
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("127.0.0.1",80,"http");
PostMethod post = new PostMethod("/index.html");
NameValuePair name = new NameValuePair("username","sdaf");
post.setRequestBody(new NameValuePair[]{name});
int t = client.executeMethod(post);
System.out.println(t); //输出 200
post.releaseConnection();
GetMethod get = new GetMethod("/ok.asp");
client.executeMethod(get);
System.out.println(get.getResponseBodyAsString()); //这里没输出
get.releaseConnection();
} public static void main(String[] args) throws HttpException, IOException {
new Test();
}}
>HttpClient client = new HttpClient();
>client.getHostConfiguration().setHost("127.0.0.1",80,"http");
>PostMethod post = new PostMethod("/index.html");
>NameValuePair name = new NameValuePair("username","sdaf");
>post.setRequestBody(new NameValuePair[]{name});
>int t = client.executeMethod(post);
>System.out.println(t); //输出 200
这里要用马上用post.getResponseBodyAsString()来得到回显内容,
。。
> HttpClient client = new HttpClient();
> client.getHostConfiguration().setHost("127.0.0.1",80,"http");
> PostMethod post = new PostMethod("/index.html");
> NameValuePair name = new NameValuePair("username","sdaf");
> post.setRequestBody(new NameValuePair[]{name});
> int t = client.executeMethod(post);
> System.out.println(t); //输出 200
这里要用马上用post.getResponseBodyAsString()来得到回显内容,我这个表单是提交给 ok.asp我想知道的是 我的值 有没有 传给 ok.asp 就可以了
name=Request.Form("username")
%>
<%= name%>如果值传到这里了GetMethod get = new GetMethod("/ok.asp");
client.executeMethod(get);
System.out.println(get.getResponseBodyAsString()); //这里没输出
get.releaseConnection();怎么得不到内容
希望对你能有所帮助。