我怎么能改变WebView#PostUrl()的CONTENT-TYPE?

Nov*_*oel 6 post android content-type webview

在Android WebView中.

我正在尝试使用带有postData的WebView#postUrl().但我找不到改变请求内容类型的方法.它始终是"application/x-www-form-urlencoded".

我怎么能改变呢?

    StringBuilder sb = new StringBuilder();
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
    sb.append("<resource>\r\n");
    sb.append("<element a=\"a\" b=\"b\"/>\r\n"); 
    sb.append("</resource>");
    String postData = sb.toString();

    mWebView.postUrl(url, postData.getBytes());
Run Code Online (Sandbox Code Playgroud)

谢谢!

小智 0

WebView文档来看,您似乎一直使用默认的content-type. 我发现对于解析端点中的数据很有帮助API,因为我无法更改content-typeapplication/json或更容易理解的内容。