【发布时间】:2011-05-21 19:54:22
【问题描述】:
我正在尝试通过 Internet 上的基本教程来学习 RichFaces 的基础知识。我正在使用这个开发环境:
- Eclipse Helios 服务版本 2(内部版本 ID:20110218-0911)
- Glassfish 开源版 3.1 (插件安装在 Eclipse 中)。
- RichFaces 4.0.0 Final(已添加 jar 在我的项目中的 WEB-INF/lib 中)
但是,当我尝试使用 Glassfish 部署 webapp 时,我收到错误:HTTP 404 Not Found:
请求的资源 (/JSFR4/test.jsf) 不可用。
我知道这是一个“找不到文件”错误,但问题是我在任何应用程序中都遇到了同样的错误,我不知道出了什么问题。在 Glassfish 管理控制台中部署了 webapp,当我从这个控制台启动它时,我遇到了同样的错误。
server.log 没有记录任何错误。
你能帮帮我吗?我做错了什么?
这是为项目生成的 web.xml:
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<description>Facelets StarterKit</description>
<display-name>JSFR4</display-name>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</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>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
这是为项目生成的 faces-config:
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<description>Facelets StarterKit</description>
<display-name>JSFR4</display-name>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</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>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
这是我的 xhtml 文件(很简单)
<f:view>
<h:head></h:head>
<h:body>
<rich:panel header="RichFaces Example">
<ul>
<li>This is an Example of Richfaces</li>
<li>A JSF Library</li>
</ul>
</rich:panel>
</h:body>
</f:view>
感谢大家
【问题讨论】:
-
它是否适用于
/faces/...而不是.jsf? -
@Bozho 不,它不起作用。我尝试了网址:localhost:8081/faces,我得到了同样的错误。
-
@Bozho 另外,我已经尝试过:localhost:8081/faces/test.jsf(和 test.xhtml),但我仍然遇到问题。在web.xml中,默认路径是:/faces/*,为什么不行?
-
和
http://localhost:8081/JSFR4/faces/test? -
遗憾的是,不,这就是我得到的:imageshack.us/f/804/404w.png - 这是 Glassfish 管理控制台中 web 应用程序的状态:imageshack.us/f/151/glassfish.png
标签: eclipse jsf jsf-2 richfaces