模拟器下可以正常请求/响应。部署到真机(诺基亚5230 E72等)之后无法正确响应。尤其是在E72中连异常信息都不见了。
贴一下代码:
这段代码,是为了获取“将要跳转到的新地址”(然后我在另一个方法里面,重新发送请求到新的url去)。因为我怕某些设备不能正确的支持“自动跳转”。之前在模拟器测试通过,可是到了真机环境完全不行。聪明反被聪明误。
J2ME真机调试又很麻烦。请各位高手帮忙!!!
贴一下代码:
public static String getHeaderFieldNewURL(String url) throws Exception{
try {
HttpConnection conn = (HttpConnection) Connector.open(url,Connector.READ_WRITE);
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
conn.setRequestMethod(HttpConnection.POST);
//conn.setFollowRedirects();
int responseCode =conn.getResponseCode();//
//302 Redirect
if(responseCode==HttpConnection.HTTP_MOVED_TEMP){
String newUrl =conn.getHeaderField("Location");//new_uri is null on some devices
conn.close();
return newUrl;
}else{
conn.close();
return "";
}
} catch (Exception e) {
//throw new Exception("Response status not OK");
e.printStackTrace();
return null ;
}
这段代码,是为了获取“将要跳转到的新地址”(然后我在另一个方法里面,重新发送请求到新的url去)。因为我怕某些设备不能正确的支持“自动跳转”。之前在模拟器测试通过,可是到了真机环境完全不行。聪明反被聪明误。
J2ME真机调试又很麻烦。请各位高手帮忙!!!