大家好,遇到一个很奇怪的问题。我用httpclient技术来连接百姓网(www.baixing.com)但是总是连接不上,在下面代码的红色一行停住,ping通没问题,telnet也没问题。同样的代码换一个网站都ok的!
public static void main(String[] args) {
HttpClient httpClient = new HttpClient();
String url="http://shanghai.baixing.com";
System.out.println("开始链接:"+url);
GetMethod get=new GetMethod(url);
get.getParams().setContentCharset("utf-8");
String responseString="";
try {
[color=red][b]int status = httpClient.executeMethod(get); //这一行执行不过去没反应了。[/b][/color]
System.out.println("status:"+get.getStatusCode());
responseString=get.getResponseBodyAsString();//获得链接数据
get.releaseConnection();
} catch (HttpException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
System.out.println("responseString="+responseString);
}