android服务器返回404,android - 离子请求仅在Android上返回404,在Chrome中它可以正常工作 - 堆栈内存溢出...

如果之前的解决方案不适用于离子3.感谢@rickie终于真正解决了三天的疯狂! 现在还可以。 转到\\platforms\\android\\CordovaLib\\src\\org\\apache\\cordova\\engine\\SystemWebViewClient.java并注释这些行:

public WebResourceResponse shouldInterceptRequest(WebView view, String url) {

try {

// Check the against the whitelist and lock out access to the WebView directory

// Changing this will cause problems for your application

/* if (!parentEngine.pluginManager.shouldAllowRequest(url)) {

LOG.w(TAG, "URL blocked by whitelist: " + url);

// Results in a 404.

return new WebResourceResponse("text/plain", "UTF-8", null);

}*/

CordovaResourceApi resourceApi = parentEngine.resourceApi;

Uri origUri = Uri.parse(url);

// Allow plugins to intercept WebView requests.

Uri remappedUri = resourceApi.remapUri(origUri);

if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {

CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);

return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);

}

// If we don't need to special-case the request, let the browser load it.

return null;

} catch (IOException e) {

if (!(e instanceof FileNotFoundException)) {

LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);

}

// Results in a 404.

return new WebResourceResponse("text/plain", "UTF-8", null);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值