我正在使用xampp运行本地服务器。我有一些html文件。我可以从我的电脑浏览器和我的iphone,我的Android手机和Windows手机上运行这些文件。
然而 当我尝试使用BlackBerry时,我收到了消息:
HTTP Error 403: Forbidden . You are not authorized to view this page. Please try loading a different page.
如果我按下查看Details
:
The following error was encountered while trying to retrieve the URL : myServersUrl
Access Denied
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.
现在我非常小心地连接到相同的wifi,因为运行服务器的计算机已连接,我正确输入ip,因为我对其他连接的手机没有问题,我的3g关闭了所以我知道它会使用wifi。此外,我可以从浏览器打开任何页面,这意味着我在手机上有互联网。 启用BIS / BES 。
我知道为什么我不能在我的本地服务器上连接?
我尝试像这样连接:
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(myBrowserFieldConfig);
add(browserField);
//attaching the udid on the URL
browserField.requestContent("http://192.123.5.112/Server_CityInfo/jMobile.html?" + udid);
和
public static HttpConnection getHttpConnection(String url, byte[] postData) {
HttpConnection conn = null;
OutputStream out = null;
try {
conn = (HttpConnection) new ConnectionFactory().getConnection(url).getConnection();
if (conn != null) {
if (postData == null) {
conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
} else {
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty("Content-Length", String.valueOf(postData.length));
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
out = conn.openOutputStream();
out.write(postData);
out.flush();
}
if (conn.getResponseCode() != 0) {
return conn;
}
}
} catch (Exception e) {
} finally {
try {
out.close();
} catch (Exception e2) {
}
}
//Only if exception occurs, we close the connection.
//Otherwise the caller should close the connection himself.
try {
conn.close();
} catch (Exception e1) {
}
return null;
}
答案 0 :(得分:1)
如果您从设置连接的BlackBerry应用程序中包含相关代码,将会有所帮助。如果您没有使用ConnectionFactory,则必须添加appender以确保连接路由到您期望的传输。这就是包含代码有用的原因。