日期:2014-05-17  浏览次数:20855 次

HttpClient页面如何跳转
请教各位大神,本人用httpclient3.1中的header传值到另外一个页面,
值是传过去了,页面却没有跳转过去,页面应该如何跳转?望各位指教。
主要代码如下:

HttpClient client = new HttpClient();
HeadMethod method = new HeadMethod("http://www.baidu.com");

method.setFollowRedirects(true);
method.setRequestHeader("baidu", "baidu");

int code = client.executeMethod(method);

if(code == 200){
    Header[] head = method.getRequestHeaders();
    System.out.println("test");
}



------解决方案--------------------
你说的是打开一个页面地址啊?
public class Test {

public static void main(String[] args) throws Exception{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.baidu.com");
}
}

------解决方案--------------------
你那个是模拟了请求。
------解决方案--------------------
引用:
Quote: 引用:

你说的是打开一个页面地址啊?
public class Test {

public static void main(String[] args) throws Exception{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.baidu.com");
}
}

我主要是想用httpheader传值,这样的话不能传值了吧?


你直接连接后面跟参数就行,如果要把数据放入头信息中
就是post请求方式。如果我没记错的话,如果是post请求方式要涉及到
web跨域