简体   繁体   English

richfaces + index.xhtml有错误

[英]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.

相关问题 /faces/index.xhtml在ExternalContext中找不到作为Glassfish中的资源 - /faces/index.xhtml Not Found in ExternalContext as a Resource in Glassfish 除index.xhtml外,未执行JSF页面 - JSF pages not being executed except index.xhtml welcome-file index.xhtml提供“在ExternalContext中找不到”作为资源 - welcome-file index.xhtml gives Not Found in ExternalContext as a Resource 如何让Glassfish自动“找到”index.xhtml并通过JSF呈现它 - How to get Glassfish to automatically “find” the index.xhtml and render it through JSF javax.el.PropertyNotWritableException: /index.xhtml @29,118 value=&quot;&quot;: 设置操作的非法语法 - javax.el.PropertyNotWritableException: /index.xhtml @29,118 value=“”: Illegal Syntax for Set Operation 警告:/index.xhtml @ 22,110 target =“#{menuTab.action}”:在com.menu.MenuTab类型上写入“ action”时出错 - WARNING: /index.xhtml @22,110 target=“#{menuTab.action}”: Error writing 'action' on type com.menu.MenuTab 在RichFaces中从xhtml访问Bean对象方法 - Accessing bean object methods from xhtml in RichFaces JBoss Richfaces:如何向rich:xhtml实现中的日历提供不同的验证消息? - JBoss Richfaces: How to provide a different validation message to rich:calendar from within the xhtml implementation? 如何使用IntelliJ验证XHTML页面上的JSF错误? - How to validate JSF errors on XHTML pages with IntelliJ? 在使用Richfaces和Facelets开发.xhtml文件时,如何删除在Eclipse的Java构建路径中找不到的Message Ui:include? - How to remove Message Ui:include not found on java build path in eclipse, While developing .xhtml file using richfaces and facelets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM