我用的是BB8900模拟器。我正在尝试连接url并获得响应码302。这是什么意思?下面是我的代码片段:
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
.....
connection = (HttpConnection)Connector.open(url);
responseCode = connection.getResponseCode();发布于 2012-04-26 16:46:49
An HTTP 302 is a 'temporary redirect'。你需要处理它。
按照标准,如果你得到一个302响应,响应将包含一个带有重定向的'Location‘头字段:
Client request:
GET /index.html HTTP/1.1
Host: www.example.com
Server response:
HTTP/1.1 302 Found
Location: http://www.redirected-address.example.com/您需要从响应中提取新的URL。(使用getHeaderField("Location")执行此操作)。然后在获得的新URL上执行相同的方法。
另外两点:
https://stackoverflow.com/questions/10329779
复制相似问题