【问题标题】:JSF works in Firefox but blank page in Internet ExplorerJSF 在 Firefox 中工作,但在 Internet Explorer 中是空白页
【发布时间】:2014-06-27 19:23:30
【问题描述】:

我有一个 login.xhtml 文件,它在 Firefox 中显示良好,但是当我在 Internet Explorer 中打开同一页面时,我得到一个空白页面,其中只有 CSS 文件设置的背景颜色。我试过IE8和IE10。在我的任何其他 JSF 项目中,我都没有遇到过在 IE 中显示 JSF 代码的问题。同样,该程序在 Firefox 中完美运行。有关如何解决此问题的任何建议?

这是我的 login.xhtml 文件:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">
<h:head>
    <f:facet name="first">
        <meta http-equiv="X-UA-Compatible" content="IE=8" />
    </f:facet>
    <f:facet name="last">   
        <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
        <link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/global.css" />
        <title>Annual Review</title>
    </f:facet>      
</h:head>

<h:body>
<p:layout fullpage="true" >

<p:layoutUnit position="north" size="80" minSize="80" maxSize="80">                 
    <p:panelGrid styleClass="menuBarGrid" columns="2">
        <p:graphicImage url="/css/NeedhamLogo2.bmp" />              
        <h:outputText value="Annual Compliance Questionnaire" />                    
    </p:panelGrid>
</p:layoutUnit>

</p:layout>
</h:body>

</html>

还有我的 web.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>AnnualReview</display-name>
  <welcome-file-list>
    <welcome-file>login.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
   <resource-ref>
        <res-ref-name>jdbc/annual_review</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

我正在使用 JSF 2.2、Primefaces 4.0 和 Glassfish 4。

【问题讨论】:

    标签: internet-explorer jsf-2


    【解决方案1】:

    我将 web.xml 文件中的 &lt;servlet-mapping&gt;&lt;url-pattern&gt;*.xhtml 更改为 /faces/*,页面现在显示在 IE 中。

    【讨论】:

      【解决方案2】:

      为什么不使用“outputStylesheet”而不是“link”!我确实认为放弃 JSF 组件根本不是一个好主意。 如果你的资源文件夹中有一个 css 文件夹,你应该试试这个:

      <h:outputStylesheet name="global.css" library="css" />
      

      你最好也改变你的 p:graphicImage。使用这两个属性而不是纯 url。我的意思是“名称”和“图书馆”。

      【讨论】:

        【解决方案3】:

        这似乎是因为 .ui-layout-unit 的可见性 = 隐藏。

        在你的 css 中覆盖 .ui-layout-unit 为:

        .ui-layout-unit{
            overflow-x:visible !important; 
            overflow-y:visible !important;
        

        }

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-09-13
          • 1970-01-01
          • 1970-01-01
          • 2016-03-04
          • 1970-01-01
          • 1970-01-01
          • 2012-04-06
          • 2015-02-16
          相关资源
          最近更新 更多