CSS文件未加载浏览器报警告:Resource interpreted as Stylesheet but transferred with MIME type text/html

JavaWeb项目中CSS样式丢失

问题:bootstrap.css未完成加载,但响应正常

错误定位:filter过滤器写了一句response.setContentType("text/html;charset=utf-8");

将css的响应格式也设置为“text/html”,浏览器识别错误

解决方法:

请求css文件不设置响应格式

重新启动tomcat即可

原文地址:https://www.cnblogs.com/MFlowers/p/11304225.html