浏览器将css的文件的content-type类型识别成了text/plain,但 产生此问题的根本原因未找到。
修改注册表、配置web.xml、配置tomcat都无效。
最后只能添加或修改filter,将content-type修改成 text/css
import org.springframework.web.util.UrlPathHelper;
public class LocaleFilter extends OncePerRequestFilter {
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
//chain.doFilter(request, response)前边添加此段代码
UrlPathHelper urlPathHelper = new UrlPathHelper();
String path = urlPathHelper.getPathWithinApplication(request);
if(path.endsWith(".css")){
response.setContentType("text/css");
}
//end
chain.doFilter(request, response);
}
}