2010-11-02 54 views

回答

12

它应该是类似于:

HttpClient client = new DefaultHttpClient(); 
HttpParams params = client.getParams(); 
HttpClientParams.setRedirecting(params, false); 
HttpGet method = new HttpGet("http://forecast.weather.gov/zipcity.php?inputstring=90210"); 
HttpResponse resp = client.execute(method); 
String location = resp.getLastHeader("Location").getValue(); 

编辑:我不得不做一些小的调整,但经我测试上述作品。

+0

你怎么能够发现这一点?我正在使用.getAllHeaders()函数并将它们全部打印出来,并且未列出位置标题。 – joepetrakovich 2010-11-02 02:01:27

+0

@Petra,使用LiveHttpHeaders和Firebug。我会很快发布一个例子。你使用的是哪个版本的HttpClient? – 2010-11-02 02:02:03

+0

Android 2.2上的org.apache.http.client模块 – joepetrakovich 2010-11-02 02:08:58

相关问题