我正在使用jsf2.0与primefaces.My应用程序工作正常,所有浏览器包括IE8 …但当我在IE9中运行我的应用程序我的内部样式表甚至没有采取浏览器(IE9)..样式被打破.
我的头上的css:
<h:head> <Meta http-equiv="X-UA-Compatible" content="IE=9" /> <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Chennai Volunteers</title> <link href="cv_website_styles.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="css/style.css"/> <script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/script.js"></script> </h:head>@H_403_5@我在控制台中遇到了以下错误
java.lang.IllegalArgumentException: ContentTypeList does not contain a supported content type: text/css at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.selectContentType(HtmlRendererUtils.java:1905) at org.apache.myfaces.renderkit.html.HtmlRenderKitImpl.createResponseWriter(HtmlRenderKitImpl.java:223) at org.apache.myfaces.shared_impl.view.JspViewDeclarationLanguageBase.renderView(JspViewDeclarationLanguageBase.java:154) at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263) at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)@H_403_5@提前致谢.
解决方法
我检查了你的网站chennaivolunteers.org,我注意到FacesServlet已映射到/ faces / *的URL模式而不是* .xhtml.因为你只使用亲戚< link>和< script>资源引用,它们(不必要地)也会通过FacesServlet.
IE9为CSS文件发送一个text / css的Accept-Header,而其他浏览器发送一个text / css; * / *的Accept-Header. FacesServlet本身不应该响应text / css请求.
>摆脱/ faces / *映射并用* .xhtml替换它.
<servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping>@H_403_5@>在< link>中使用域相对网址和< script> (和< img>)引用,以便它们永远不会通过/ faces路径.
<ui:param name="root" value="#{request.contextPath}/" /> <link href="#{root}cv_website_styles.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="#{root}css/style.css"/> <script type="text/javascript" src="#{root}js/jquery.min.js"></script> <script type="text/javascript" src="#{root}js/script.js"></script>@H_403_5@或者使用< base>标记,或使用< h:outputStylesheet>和< h:outputScript>用一个名字代替.
你的网站在几个资源上已经有相当多的404.修复它.检查浏览器内置Web开发人员工具集的“网络”,“网络”部分(按IE9 / Chrome / Firebug中的F12).