【发布时间】:2014-08-31 02:11:03
【问题描述】:
将 JSF 2.2 与 Tomcat 7.0 一起使用,尝试使用 web.xml 在服务器上运行我的项目,但我的 JSF 从未呈现。通过在tomcat上运行我的index.xhtml文件时,jsf显示没有任何问题。这是我的 web.xhtml:
<?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"
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>ProcessOrderNewGreg</display-name>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</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>*.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>
<welcome-file-list>
<welcome-file>ProcessOrderNewGreg/index.xhtml</welcome-file>
<welcome-file>ProcessOrderNewGreg/index.xhtml/index.jsf</welcome-file>
<welcome-file>ProcessOrderNewGreg/index.xhtml/index.htm</welcome-file>
<welcome-file>ProcessOrderNewGreg/index.xhtml/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
通过 run as 运行 index.xhtml 时的我的网址:
http://localhost:8080/ProcessOrderNewGreg/index.xhtml
【问题讨论】:
-
没有渲染的页面,是否有.jsf作为后缀?例如,
http://localhost:8080/ProcessOrderNewGreg/example.jsf? -
不,它们都是 .xhtml。但我能够让我的组件正常工作。感谢您的帮助!
-
如果你曾经使用过faces-redirect,你可能会遇到麻烦,因为它们附加了.jsf...无论如何,祝你好运!
-
@BalusC shoot 我不知道我怎么错过了 url 映射。对不起
-
@rion18 你建议我如何明智地进行编辑以避免可能的麻烦?
标签: jsf tomcat primefaces