Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry-HttpConnection响应代码在模拟器中返回为301而不是200_Blackberry_Blackberry Simulator - Fatal编程技术网

Blackberry-HttpConnection响应代码在模拟器中返回为301而不是200

Blackberry-HttpConnection响应代码在模拟器中返回为301而不是200,blackberry,blackberry-simulator,Blackberry,Blackberry Simulator,下面的代码在设备上运行良好,但在模拟器中,我得到的响应是301而不是200。有人知道为什么会这样以及如何修复吗 ConnectionFactory factory = new ConnectionFactory(); factory.setConnectionTimeout(10000); ConnectionDescriptor connDesc = factory.getConnection("http://google.com"); if (connDesc != null)

下面的代码在设备上运行良好,但在模拟器中,我得到的响应是301而不是200。有人知道为什么会这样以及如何修复吗

 ConnectionFactory factory = new ConnectionFactory();
 factory.setConnectionTimeout(10000);

 ConnectionDescriptor connDesc = factory.getConnection("http://google.com");

 if (connDesc != null)
 {               
       HttpConnection con = (HttpConnection)connDesc.getConnection();
       System.out.println("Response code "+con.getResponseCode();                        
       int statusCode = con.getResponseCode();
       if (statusCode == HttpConnection.HTTP_OK)
       {
            System.out.println("connected");
       }
 }
上面的代码解释了为什么它将响应返回为301而不是200


谢谢

任何考虑回复的人都可以在这里查看对类似问题的回复:请访问www.google.com