Exception information:
Resource interpreted as Stylesheet but transferred with MIME type text/html:
Possible causes
The filter or some place turns all resource requests to text/HTML
Inspection method
Using browser to view request header and response header
Mainly check the content type of request header and response header
The style sheet should be text/CSS, and the request sent to the server and the server’s response to the client should be text/CSS
The problem I personally encountered in the project is that when using the filter to code all requests, the CSS file is also processed
The filter code before modification is
System.out.println("**********AllFilter start work*********");
HttpServletRequest request=(HttpServletRequest)req;
HttpServletResponse response=(HttpServletResponse)res;
response.setCharacterEncoding("text/html; charset=UTF-8");
Treatment method
The request should be classified. When it is a kind of file such as CSS, it is requested in the original way and not processed. Other requests are processed again. The modified code is as follows:
System.out.println("**********AllFilter start work*********");
HttpServletRequest request=(HttpServletRequest)req;
HttpServletResponse response=(HttpServletResponse)res;
String url=request.getRequestURI();
System.out.println("url:" +url);
if(url.indexOf(".css")>0||url.indexOf(".js")>0||url.indexOf(".png")>0) {
chain.doFilter(request, response);
return;
}
response.setContentType("text/html;text/html; charset=UTF-8");
Similar Posts:
- How to Solve Error: Preflight response is not successful
- The interface method is not rewritten, and the idea does not report an error.
- Python3 Use urlliburlopen error EOF occurred in violation of protocol (_ssl.c:841)
- What does HTTP status code 304 mean
- [Solved] Typeerror: can read property ‘index of’ of null
- [Solved] HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
- The differences between response. Getwriter(). Write() and response. Getwriter(). Print(), as well as pritwriter object and out object
- Tomcat set x-frame-option
- SpringMvc Error:java.lang.IllegalStateException
- Mixed Content: The page at was loaded over HTTPS, but requested an insecure image.