JAVA WEB Resource interpreted as Stylesheet but transferred with MIME type text/html

在本地tomcat上时,用Chrome访问都没问题,CSS能加载且有效果,系统正常;

部署到端Tomcat时,Chrome访问时能加载CSS文件,但是没有样式效果;

我的项目中加了过滤器,统一了返回的类型为text/html,根据请求类型,设置响应内容类型;


		// pass the request along the filter chain
		System.out.println("----调用service之前执行一段代码----");
		HttpServletRequest hrequest = (HttpServletRequest) request;
		HttpServletResponse hrresponse = (HttpServletResponse) response;
		HttpSession session = hrequest.getSession();
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String contentType=hrequest.getHeader("Accept");
		System.out.println("--------"+contentType);
		response.setContentType(contentType==null?"text/html;charset=UTF-8":contentType+";charset=UTF-8");
		
		
		/**
		 * String getFilterName();//得到filter的名称。 String getInitParameter(String
		 * name);//返回在部署描述中指定名称的初始化参数的值。如果不存在返回null. Enumeration
		 * getInitParameterNames();//返回过滤器的所有初始化参数的名字的枚举集合。 public
		 * ServletContext getServletContext();//返回Servlet上下文对象的引用。
		 */
		String url = hrequest.getRequestURI();
		String params = hrequest.getQueryString();
		String Path = hrequest.getServletPath();
		log.debug(url);
		log.debug(params);
		log.debug(Path);
		/**

感谢 https://blog.csdn.net/sky_cui/article/details/86703706

你可能感兴趣的:(java,css,javascript)