【发布时间】:2013-08-06 14:56:53
【问题描述】:
我正在使用 xampp 运行本地服务器。我有一些 html 文件。我可以从我的计算机浏览器和我的 iphone、我的 android 手机和 windows 手机上运行这些文件。
但是当我尝试使用黑莓手机时,我收到了消息:
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;
}
【问题讨论】:
-
这个“本地服务器”是否是公司网络的一部分,也托管您的 BES 服务器?或者,你只是在家里用自己的服务器试试这个?
-
我正在家里尝试这个。对不起,我有 BIS 不是 BES。
-
你真的使用getHttpConnection()吗?
-
是的,但这是向我的后端服务器发送一个 json 文件。与我的前端 jquery mobile 无关。我开始认为浏览器可能不支持它。
标签: blackberry xampp localhost http-status-code-403 localserver