我正在尝试使用JSF 1.2创建一个简单的UI(我的客户端多年来一直使用这个版本,而现有的应用程序运行这个版本 - 所以无法移动到2.x)。 UI用于上载excel文件并在数据表上显示内容。 我正在使用JSF 1.2。我尝试使用JSP来做这件事,一切正常。现在我试图转向XHTML。当我访问应用程序URL时,IE(v8)不会呈现JSF页面 - 而是打开一个对话框,提示打开/保存选项。使用Chrome,我只看到我的XHTML呈现的Head部分。剩下的部分不是。我在这里提供了以下内容:
的web.xml xhtml文件 查看来自Chrome的来源
有人能指出我做错了什么/我在哪里?
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>DEMSFileUpload</display-name>
<welcome-file-list>
<welcome-file>awardwinners.jsf</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.webapp.filter.ExtensionsFilter
</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>1000m</param-value>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>10000k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
</web-app>
我的XHTML文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:x="http://myfaces.apache.org/tomahawk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link href="dems.css" rel="stylesheet" type="text/css"></link>
<title>DEMS PIA/AIM Award Winners Upload</title>
</head>
<body>
<h3
style="font-family: Arial, Verdana, Helvetica; font-size: 12px; color: #FFFFFF; font-weight: bold; text-decoration: none; text-align: left; background-color: #669999; cursor: none; width: 950px;">
PIA/AIM Award Winners Upload</h3>
<h:form enctype="multipart/form-data">
<h:panelGrid border="0" columns="3">
<h:outputText value="File " styleClass="txt"></h:outputText>
<x:inputFileUpload id="file" value="#{fileUpload.uploadedFile}"
required="false" size="40" />
<h:commandButton action="#{fileUpload.upload}" value="Upload"></h:commandButton>
</h:panelGrid>
<h:dataTable value="#{fileUpload.listFromSheet}" var="awardwinner"
styleClass="w950" headerClass="txt cjHeader alignLeft"
rowClasses="dataTableRow,alternateDataTableRow"
style="border-spacing: 0px;" frame="box">
<h:column>
<f:facet name="header">
<h:outputText style="padding-left: 5px" value="Center Id" />
</f:facet>
<h:outputText style="padding-left: 5px" styleClass="txt"
value="#{awardwinner.centerId}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Employee Id" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.employeeID}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Position Id" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.positionID}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Line Make" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.lineMake}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Award Year" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.awardYear}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Achieved Level" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.achievedLevel}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Awards" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.awards}" />
</h:column>
</h:dataTable>
</h:form>
</body>
</html>
查看 - &gt;来自Chrome的来源:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:x="http://myfaces.apache.org/tomahawk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link href="dems.css" rel="stylesheet" type="text/css"></link>
<title>DEMS PIA/AIM Award Winners Upload</title>
</head>
<body>
<h3
style="font-family: Arial, Verdana, Helvetica; font-size: 12px; color: #FFFFFF; font-weight: bold; text-decoration: none; text-align: left; background-color: #669999; cursor: none; width: 950px;">
PIA/AIM Award Winners Upload</h3>
<h:form enctype="multipart/form-data">
<h:panelGrid border="0" columns="3">
<h:outputText value="File " styleClass="txt"></h:outputText>
<x:inputFileUpload id="file" value="#{fileUpload.uploadedFile}"
required="false" size="40" />
<h:commandButton action="#{fileUpload.upload}" value="Upload"></h:commandButton>
</h:panelGrid>
<h:dataTable value="#{fileUpload.listFromSheet}" var="awardwinner"
styleClass="w950" headerClass="txt cjHeader alignLeft"
rowClasses="dataTableRow,alternateDataTableRow"
style="border-spacing: 0px;" frame="box">
<h:column>
<f:facet name="header">
<h:outputText style="padding-left: 5px" value="Center Id" />
</f:facet>
<h:outputText style="padding-left: 5px" styleClass="txt"
value="#{awardwinner.centerId}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Employee Id" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.employeeID}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Position Id" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.positionID}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Line Make" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.lineMake}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Award Year" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.awardYear}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Achieved Level" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.achievedLevel}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Awards" />
</f:facet>
<h:outputText styleClass="txt" value="#{awardwinner.awards}" />
</h:column>
</h:dataTable>
</h:form>
</body>
</html>