JSF 中的简单程序抛出 404 错误
我是 jsf Rich Faces 编程的新手。我正在创建一个名为“Greeter”的简单程序。我已经包含了与 RichFaces 相关的所有 jar 文件 richfaces-api-3.1.4.GA.jar richfaces-impl-3.1.4.GA.jar richfaces-ui-3.1.4.GA.jar jhighlight-1.0.jar commons-logging.jar commons-beanutils.jar commons-collections.jar commons-digester.jar
web.xml 文件是
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Plugging the "Blue Sky" skin into the project -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<!-- Defining and mapping the RichFaces filter -->
<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>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml 是
<?xml version='1.0' encoding='UTF-8'?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<description>UsernName Bean</description>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>demo.user</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>name</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
</managed-bean>
</faces-config>
index.jsp 文件是
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<head>
<title>RichFaces Greeter</title>
</head>
<body>
<f:view>
<a4j:form>
<rich:panel header="RichFaces Greeter" style="width: 315px">
<h:outputText value="Your name: " />
<h:inputText value="#{user.name}" >
<f:validateLength minimum="1" maximum="30" />
</h:inputText>
<a4j:commandButton value="Get greeting" reRender="greeting" />
<h:panelGroup id="greeting" >
<h:outputText value="Hello, " rendered="#{not empty user.name}" />
<h:outputText value="#{user.name}" />
<h:outputText value="!" rendered="#{not empty user.name}" />
</h:panelGroup>
</rich:panel>
</a4j:form>
</f:view>
</body>
</html>
,user.java 文件是
package demo;
public class user {
private String name="";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
,浏览器上的错误消息是
HTTP Status 404 - /Gree/index.jsp
类型状态报告
消息 /Greeter/ index.jsp
描述 请求的资源 (/Greeter/index.jsp) 不可用。
日志文件消息是
2011 年 4 月 10 日 12:05:05 AM org.apache.coyote.http11.Http11Protocol init 信息:在端口 8080 上初始化 Coyote HTTP/1.1 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.startup.Catalina 加载 信息:初始化在 1000 毫秒内完成 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.core.StandardService 启动 信息:开始服务 Catalina 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.core.StandardEngine 启动 信息:启动 Servlet 引擎:Apache Tomcat/5.0.16 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.core.StandardHost 启动 信息:XML 验证已禁用 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.core.StandardHost getDeployer 信息:创建主机部署程序以进行直接部署(非 jmx ) 2011 年 4 月 10 日 12:05:05 上午 org.apache.catalina.core.StandardHostDeployer 安装 INFO: 处理上下文配置文件 URL 文件:G:\Tomcat5.0\conf\Catalina\localhost\admin.xml 2011 年 4 月 10 日 12:05:06 上午 org.apache.struts.util.PropertyMessageResources 信息:初始化,config='org.apache.struts.util.LocalStrings',returnNull=true 2011 年 4 月 10 日 12:05:06 上午 org.apache.struts.util.PropertyMessageResources 信息:初始化,config='org.apache.struts.action.ActionResources',returnNull=true 2011 年 4 月 10 日上午 12:05:07 org.apache.struts.util.PropertyMessageResources 信息:初始化,config='org.apache.webapp.admin.ApplicationResources',returnNull=true 2011 年 4 月 10 日 12:05:09 上午 org.apache.catalina.core.StandardHostDeployer 安装 INFO:处理上下文配置文件 URL 文件:G:\Tomcat5.0\conf\Catalina\localhost\balancer.xml 2011 年 4 月 10 日 12:05:09 上午 org.apache.catalina.core.StandardHostDeployer 安装 INFO:处理上下文配置文件 URL 文件:G:\Tomcat5.0\conf\Catalina\localhost\manager.xml 2011 年 4 月 10 日 12:05:09 上午 org.apache.catalina.core.StandardHostDeployer 安装 信息:从 URL 文件在上下文路径 /Gree 安装 Web 应用程序:G:\Tomcat5.0\webapps\Gree 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardContext 启动 严重:过滤器启动错误 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardContext 启动 严重:由于之前的错误,上下文启动失败 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardHostDeployer 安装 信息:在 URL 文件的上下文路径 /jsp-examples 处安装 Web 应用程序:G:\Tomcat5.0\webapps\jsp-examples 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardHostDeployer 安装 信息:从 URL 文件的上下文路径安装 Web 应用程序:G:\Tomcat5.0\webapps\ROOT 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardHostDeployer 安装 信息:在 URL 文件的上下文路径 /servlets-examples 处安装 Web 应用程序:G:\Tomcat5.0\webapps\servlets-examples 2011 年 4 月 10 日上午 12:05:10 org.apache.catalina.core.StandardHostDeployer 安装 信息:从 URL 文件在上下文路径 /tomcat-docs 安装 Web 应用程序:G:\Tomcat5.0\webapps\tomcat-docs 2011 年 4 月 10 日上午 12:05:10 org.apache.coyote.http11.Http11Protocol 启动 信息:在端口 8080 上启动 Coyote HTTP/1.1 2011 年 4 月 10 日上午 12:05:11 org.apache.jk.common.ChannelSocket 初始化 信息:JK2:ajp13 正在监听 /0.0.0.0:8009 2011 年 4 月 10 日 12:05:11 AM org.apache.jk.server.JkMain 启动 信息:Jk 运行 ID=0 时间=0/47 config=G:\Tomcat5.0\conf\jk2.properties 2011 年 4 月 10 日 12:05:11 上午 org.apache.catalina.startup.Catalina 启动 信息:服务器在 5797 毫秒内启动,
请帮助我摆脱此错误。我已经尝试了很多,但出现了错误消息。提前致谢。
I new in jsf rich faces programing .A am creating a simple programme called "Greeter".I have included all the jar files related to RichFaces
richfaces-api-3.1.4.GA.jar
richfaces-impl-3.1.4.GA.jar
richfaces-ui-3.1.4.GA.jar
jhighlight-1.0.jar
commons-logging.jar
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
web.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Plugging the "Blue Sky" skin into the project -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<!-- Defining and mapping the RichFaces filter -->
<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>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml is
<?xml version='1.0' encoding='UTF-8'?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<description>UsernName Bean</description>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>demo.user</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>name</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
</managed-bean>
</faces-config>
index.jsp file is
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<head>
<title>RichFaces Greeter</title>
</head>
<body>
<f:view>
<a4j:form>
<rich:panel header="RichFaces Greeter" style="width: 315px">
<h:outputText value="Your name: " />
<h:inputText value="#{user.name}" >
<f:validateLength minimum="1" maximum="30" />
</h:inputText>
<a4j:commandButton value="Get greeting" reRender="greeting" />
<h:panelGroup id="greeting" >
<h:outputText value="Hello, " rendered="#{not empty user.name}" />
<h:outputText value="#{user.name}" />
<h:outputText value="!" rendered="#{not empty user.name}" />
</h:panelGroup>
</rich:panel>
</a4j:form>
</f:view>
</body>
</html>
and user.java file is
package demo;
public class user {
private String name="";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
and error message on browser is
HTTP Status 404 - /Gree/index.jsp
type Status report
message /Greeter/index.jsp
description The requested resource (/Greeter/index.jsp) is not available.
log file message is
Apr 10, 2011 12:05:05 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on port 8080
Apr 10, 2011 12:05:05 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1000 ms
Apr 10, 2011 12:05:05 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 10, 2011 12:05:05 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.0.16
Apr 10, 2011 12:05:05 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Apr 10, 2011 12:05:05 AM org.apache.catalina.core.StandardHost getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx )
Apr 10, 2011 12:05:05 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:G:\Tomcat5.0\conf\Catalina\localhost\admin.xml
Apr 10, 2011 12:05:06 AM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
Apr 10, 2011 12:05:06 AM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
Apr 10, 2011 12:05:07 AM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', returnNull=true
Apr 10, 2011 12:05:09 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:G:\Tomcat5.0\conf\Catalina\localhost\balancer.xml
Apr 10, 2011 12:05:09 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:G:\Tomcat5.0\conf\Catalina\localhost\manager.xml
Apr 10, 2011 12:05:09 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /Gree from URL file:G:\Tomcat5.0\webapps\Gree
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardContext start
SEVERE: Context startup failed due to previous errors
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /jsp-examples from URL file:G:\Tomcat5.0\webapps\jsp-examples
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path from URL file:G:\Tomcat5.0\webapps\ROOT
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /servlets-examples from URL file:G:\Tomcat5.0\webapps\servlets-examples
Apr 10, 2011 12:05:10 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /tomcat-docs from URL file:G:\Tomcat5.0\webapps\tomcat-docs
Apr 10, 2011 12:05:10 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
Apr 10, 2011 12:05:11 AM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Apr 10, 2011 12:05:11 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/47 config=G:\Tomcat5.0\conf\jk2.properties
Apr 10, 2011 12:05:11 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5797 ms
please help me to get rid from this error . I have tried a lot but the error message is coming .Thanks in advance .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查一下您在 web.xml 中编写的代码,
这样您就可以通过index.faces而不是index.jsp来访问您的页面
Check out your code in web.xml, you have written,
So you can access your page by not index.jsp but index.faces