JSF 标签未呈现为 HTML
JSF tags not rendering as HTML
我使用 JSF 2.2 在 Eclipse 中创建了一个简单的 Web 应用程序,并通过 WebSphere 8.5 运行 创建了它。但是,当我使用 http://localhost:9082/HCVA/index.xhtml 在浏览器中拉出索引页面时,我只得到一个空白页面。我只使用 JSF 标签编写了整个网页,当我查看调试器时,我发现 JSF 标签没有呈现为 HTML。如果我添加 HTML 标签,例如 <p>test</p>
,那么它会在浏览器中显示 "test"。到目前为止,这是整个索引页:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>HCVA</title>
</h:head>
<h:body>
<h:panelGroup id="header" layout="block" styleClass="headerClass">
<h:graphicImage value="/images/NewOntarioLogo.gif" alt="Ontario Logo" border="0" />
<h:outputText value="Health Card Viewer Application"/>
<p>test</p>
</h:panelGroup>
<h:panelGroup id="navigate" layout="block">
</h:panelGroup>
<h:panelGroup id="mainContent" layout="block">
</h:panelGroup>
<h:panelGroup id="footer" layout="block" styleClass="footerClass">
<h:graphicImage value="/images/NewOntarioLogo.gif" alt="Ontario Logo" border="0" />
<br></br>
<h:outputText value="This site is maintained by the Government of Ontario, Canada."/>
<br></br>
<h:link value="PRIVACY" outcome="http://www.ontario.ca/en/general/004222"/>
<h:outputText value="|"/>
<h:link value="IMPORTANT NOTICES" outcome="http://www.ontario.ca/en/general/004222"/>
<br></br>
<h:outputText value="Copyright information:"/>
<h:link value="© Queen's Printer for Ontario, 2006" outcome="http://www.ontario.ca/en/general/004222"/>
<br></br>
<h:outputText value="Last Modified: 2009-12-12"/>
</h:panelGroup>
</h:body>
</html>
我看过其他关于此的帖子,我知道这个问题可能意味着页面未通过 FacesServlet 传递。但是,我已验证使用的请求 URL 与 FacesServlet 的 url 模式匹配。这是我的 web.xml 的样子:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>HCVA</display-name>
<context-param>
<description>
The location where state information is saved.
Valid values are 'server' (typically saved in HttpSession) and 'client' (typically
saved as a hidden field in the form.
Default is server.</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<description>
Comma-delimited list of context-relative resource paths under which the JSF implementation
will look for application configuration resources, before loading a configuration resource
named /WEB-INF/faces-config.xml (if such a resource exists).</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value></param-value>
</context-param>
<context-param>
<description>
The default suffix for extension-mapped resources that contain JSF components.
Default is '.jsp'.</description>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<description>
A human readable string describing where this particular JSF application is
in the software development lifecycle.
Valid values are 'Development', 'UnitTest', 'SystemTest' and 'Production'.
Default is 'Production'.
This parameter is not available in JSF 1.x.</description>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<description>
Monitors Faces JSP files for modifications and synchronizes a running server with
the changes without restarting the server. If this parameter is set to false or
removed from the deployment descriptor, any changes made to Faces JSP files may
not be seen by the server until it is restarted. This parameter is usually set
to true while the Faces JSP files are being developed and debugged in order to
improve the performance of the development environment.</description>
<param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
JSF runtime will be loaded and initialized when the first JSF request is processed.
This may disable custom JSF extensions, such as factories defined in the project.</description>
<param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
<param-value>true</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>
<enabled>true</enabled>
<async-supported>false</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>
*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
对此进行了很长时间的故障排除,但没有结果。任何帮助,将不胜感激。
WebSphere 8.5 不提供 JSF 2.2 实现 - 仅通过 SunRI 提供 JSF 1.2,通过 MyFaces 提供 JSF 2.0。除非您提供 third-party JSF 实现,否则您将需要更新您的应用程序以使用正确的 JSF 规范级别。
我使用 JSF 2.2 在 Eclipse 中创建了一个简单的 Web 应用程序,并通过 WebSphere 8.5 运行 创建了它。但是,当我使用 http://localhost:9082/HCVA/index.xhtml 在浏览器中拉出索引页面时,我只得到一个空白页面。我只使用 JSF 标签编写了整个网页,当我查看调试器时,我发现 JSF 标签没有呈现为 HTML。如果我添加 HTML 标签,例如 <p>test</p>
,那么它会在浏览器中显示 "test"。到目前为止,这是整个索引页:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>HCVA</title>
</h:head>
<h:body>
<h:panelGroup id="header" layout="block" styleClass="headerClass">
<h:graphicImage value="/images/NewOntarioLogo.gif" alt="Ontario Logo" border="0" />
<h:outputText value="Health Card Viewer Application"/>
<p>test</p>
</h:panelGroup>
<h:panelGroup id="navigate" layout="block">
</h:panelGroup>
<h:panelGroup id="mainContent" layout="block">
</h:panelGroup>
<h:panelGroup id="footer" layout="block" styleClass="footerClass">
<h:graphicImage value="/images/NewOntarioLogo.gif" alt="Ontario Logo" border="0" />
<br></br>
<h:outputText value="This site is maintained by the Government of Ontario, Canada."/>
<br></br>
<h:link value="PRIVACY" outcome="http://www.ontario.ca/en/general/004222"/>
<h:outputText value="|"/>
<h:link value="IMPORTANT NOTICES" outcome="http://www.ontario.ca/en/general/004222"/>
<br></br>
<h:outputText value="Copyright information:"/>
<h:link value="© Queen's Printer for Ontario, 2006" outcome="http://www.ontario.ca/en/general/004222"/>
<br></br>
<h:outputText value="Last Modified: 2009-12-12"/>
</h:panelGroup>
</h:body>
</html>
我看过其他关于此的帖子,我知道这个问题可能意味着页面未通过 FacesServlet 传递。但是,我已验证使用的请求 URL 与 FacesServlet 的 url 模式匹配。这是我的 web.xml 的样子:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>HCVA</display-name>
<context-param>
<description>
The location where state information is saved.
Valid values are 'server' (typically saved in HttpSession) and 'client' (typically
saved as a hidden field in the form.
Default is server.</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<description>
Comma-delimited list of context-relative resource paths under which the JSF implementation
will look for application configuration resources, before loading a configuration resource
named /WEB-INF/faces-config.xml (if such a resource exists).</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value></param-value>
</context-param>
<context-param>
<description>
The default suffix for extension-mapped resources that contain JSF components.
Default is '.jsp'.</description>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<description>
A human readable string describing where this particular JSF application is
in the software development lifecycle.
Valid values are 'Development', 'UnitTest', 'SystemTest' and 'Production'.
Default is 'Production'.
This parameter is not available in JSF 1.x.</description>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<description>
Monitors Faces JSP files for modifications and synchronizes a running server with
the changes without restarting the server. If this parameter is set to false or
removed from the deployment descriptor, any changes made to Faces JSP files may
not be seen by the server until it is restarted. This parameter is usually set
to true while the Faces JSP files are being developed and debugged in order to
improve the performance of the development environment.</description>
<param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
JSF runtime will be loaded and initialized when the first JSF request is processed.
This may disable custom JSF extensions, such as factories defined in the project.</description>
<param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
<param-value>true</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>
<enabled>true</enabled>
<async-supported>false</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>
*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
对此进行了很长时间的故障排除,但没有结果。任何帮助,将不胜感激。
WebSphere 8.5 不提供 JSF 2.2 实现 - 仅通过 SunRI 提供 JSF 1.2,通过 MyFaces 提供 JSF 2.0。除非您提供 third-party JSF 实现,否则您将需要更新您的应用程序以使用正确的 JSF 规范级别。