WebView中loadDataWithBaseURL与loadData加载本地html困惑
当使用webView.loadData(bodyBuffer.toString(), "text/html", "utf-8")加载本地的html代码时,如果html代码中%,则页面不能显示,显示为web page not availableness.而使用webView.loadDataWithBaseURL("about:blank",bodyBuffer.toString(), "text/html", "utf-8",null);即可正常加载,不知道为什么?期待找到正解。
loadData:
public void loadData (String data, String mimeType, String encoding) Load the given data into the WebView. This will load the data into WebView using the data: scheme. Content loaded through this mechanism does not have the ability to load content from the network.
Parameters data A String of data in the given encoding. The date must be URI-escaped -- '#', '%', '', '?' should be replaced by %23, %25, %27, %3f respectively. mimeType The MIMEType of the data. i.e. text/html, image/jpeg encoding The encoding of the data. i.e. utf-8, base64
下如API中所说的,
以上转自:http://bbs.chinaunix.net/thread-3617508-1-1.html
因为%在loadData中是非法字符。 希望对您有用