[英]richfaces + index.xhtml having errors
I have been unable to get my index.xhtml file to load properly, and I have checked all the tutorials for this. 我一直无法正确加载我的index.xhtml文件,并且我已经检查了所有教程。 Can somebody please point me in the right direction?
有人可以指出我正确的方向吗? I was only going through the tutorials on the richfaces site.
我只浏览了richfaces网站上的教程。
Below is my web.xml file: 下面是我的web.xml文件:
<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
<display-name>Greeter</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Loader</servlet-name>
<servlet-class>com.mounza.common.Loader</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<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>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
You're talking about the <welcome-file>
, right? 你在谈论
<welcome-file>
,对吧? It must point to a physically existing file, because that's internally been used by the servletcontainer to show the default resource whenever a folder is been requested. 它必须指向物理上存在的文件,因为servletcontainer在内部使用它来在请求文件夹时显示默认资源。 The servletcontainer will first check if the file exists before performing a forward on this.
servletcontainer将首先检查文件是否存在,然后再执行转发。 If the file doesn't exist, you'll just get a 404.
如果该文件不存在,您将获得404。
Combining this with JSF which get executed on a virtual URL only requires a special trick. 将其与在虚拟URL上执行的JSF相结合只需要一个特殊的技巧。 You basically need to fool the servletcontainer with a physically existing but empty
index.jsf
file there in the folder next to your real index.xhtml
file. 你基本上需要在真正的
index.xhtml
文件旁边的文件夹中使用物理上存在但空的 index.jsf
文件来欺骗servletcontainer。 This way the servletcontainer won't show a 404, but perform a forward to the file which will automatically trigger the FacesServlet
. 这样servlet容器不会显示404,而是执行转发到文件,这将自动触发
FacesServlet
。
But if you happen to already use JSF 2.x (which doesn't seem to be the case, but anyway, just for sake of completeness), then you can also just change the URL pattern of the FacesServlet
from *.jsf
(and /faces/*
) to *.xhtml
. 但是,如果你碰巧已经使用了JSF 2.x(似乎并非如此,但无论如何,只是为了完整性),那么你也可以从
*.jsf
改变FacesServlet
的URL模式(和/faces/*
)到*.xhtml
。 This way you do not need to fiddle with virtual URLs anymore. 这样您就不需要再使用虚拟URL了。 This is not possible in JSF 1.x, because the
FacesServlet
would keep calling itself in an infinite loop. 这在JSF 1.x中是不可能的,因为
FacesServlet
将继续在无限循环中调用自身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.