When I use webview, I open a page, and then if there is a 404 error, the error page is displayed.
During the use, I found that when I opened a page, a total of 7 requests were made, including 2 requests. The resource returned 404, which caused the page to be loaded, but an error interface was still displayed.
So I would like to ask, is there not only one network request when opening an http page? (Wouldn’t it only return 200 once, or 404 or something else)?
怪我咯2017-05-16 13:28:42
There will be many times, including
Document: html file itself
Resources: Image Video js file css file
Data: ajax request
etc
Browser F12 will see clearly
过去多啦不再A梦2017-05-16 13:28:42
A page includes many parts. If your page contains images, style files, data pulled from the backend, etc. It won’t be requested once, but many times.
PHP中文网2017-05-16 13:28:42
Generally, webview determines whether the loading failure is mainly to determine whether the HTML document part is 200. After the HTML is loaded, there are many places that need to be loaded asynchronously, such as obtaining css, js, pictures and other data. By rewriting onLoadResource, you can see what has been loaded. resource. As for displaying the error page, you also need to look at the server settings. Some servers will redirect you to the specified page for errors such as 404 and 502, instead of the error page that comes with the webview. This kind of page is generally It's a problem on the server side and has nothing to do with whether the machine responds to the page correctly.