【问题标题】:Add headers in webview在 webview 中添加标题
【发布时间】:2014-10-09 16:58:57
【问题描述】:

当我使用 loadData 函数时,是否可以在 webView 中添加额外的标题?

我发现了这个 loadUrl(String url, Map extraHeaders) 但这仅将标头应用于请求,如果我想使用 loadData 方法添加标头。

【问题讨论】:

    标签: android webview


    【解决方案1】:

    当我使用 loadData 函数时,是否可以在 webView 中添加额外的标题?

    不,因为没有服务器来解释标头,所以它们没有用。

    【讨论】:

      【解决方案2】:

      用header和webview创建xml文件,然后

      使用它会起作用。

      String mresult = "<html><head></head><body><p>Testing here</p></body></html>"
      
      web.loadData(mresult, "text/html; charset=UTF-8", null);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-18
        • 2019-01-06
        • 1970-01-01
        • 2010-09-27
        • 2017-02-01
        • 2011-01-17
        • 2021-06-25
        • 1970-01-01
        相关资源
        最近更新 更多