Faces Servlet无法解析在Tomcat 7上运行的jsf 2中的.xhtml页面 [英] Faces Servlet not parsing .xhtml pages in jsf 2. running on tomcat 7
问题描述
我正在尝试使用tomcat7在Eclipse中创建JSF 2.0应用程序.该项目正在成功运行,但是jsf html和核心组件未在浏览器中呈现.我认为我已经在web.xml中配置了Faces Servlet.
I am trying to create a JSF 2.0 application in eclipse with tomcat7. The project is running successfully but the jsf html and core components are not rendered in browser. I think Faces Servlet I have configured in web.xml.
以下是web.xml文件-
Following is the web.xml file -
<welcome-file-list>
<welcome-file>faces/index.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>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default)</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>
我在WEB-INF之外有index.xhtml页面.它在浏览器中显示,但是jsf组件在浏览器中看不到.谁能告诉我出什么问题了.
I have my index.xhtml page outside WEB-INF. Its shown in browser but the jsf components are not see in browser. Can anyone please tell what is going wrong.
我在WEB-INF/lib中包含了以下jar文件- 1. commons-annotations.jar 2. commons-beansutil.jar 3. commons-collection.jar 4. commons-digester.jar 5. commons-logging.jar 6. jsf-api.jar(来自mojra 2.0) 7. jsf-impl.jar(来自mojra 2.0) 8. jstl.jar 9. standard.jar
I have included following jars in WEB-INF/lib - 1. commons-annotations.jar 2. commons-beansutil.jar 3. commons-collection.jar 4. commons-digester.jar 5. commons-logging.jar 6. jsf-api.jar (from mojra 2.0) 7. jsf-impl.jar (from mojra 2.0) 8. jstl.jar 9. standard.jar
谢谢
推荐答案
尝试这些..这些是我自己一次针对我的问题指定的.
Try these .. These were specified to me for my own question once..
- 您不需要,甚至不应该包括JSF jar.这些已经是Java EE的一部分.
- 第二,您绝对不需要,也绝对不应将单独的Facelets jar与JSF 2.x结合使用. Facelets已经成为JSF 2.x的一部分.
- 您也不应包含JSTL jar. Java EE也提供了这一功能.如果您有Apache commons的commons jars,那么它们很好,但是JSF不需要它们.仅当您想直接在应用程序代码中使用它们时,才包括它们.
- 尝试获取最新的JSF(mojara 2.x).
您还可以像这样修改web.xml并尝试:
Also you can modify your web.xml like this and try:
<welcome-file-list>
<welcome-file>index.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>
当我尝试时,我删除了分别添加jsf jar的操作.它可以正常工作,显示所有jsf标签.还要确保您在xhtml页面中具有所有必需的taglib,即:
When I tried, I removed adding jsf jars separately. And it worked, displaying all the jsf tags. Also make sure you have all the required taglibs in your xhtml page, namely :
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
看看是否可行.
这篇关于Faces Servlet无法解析在Tomcat 7上运行的jsf 2中的.xhtml页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!