开发者

Simple program in JSF is throwing 404 error

开发者 https://www.devze.com 2023-02-23 13:44 出处:网络
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

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>开发者_如何学Go

                        </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 .


Check out your code in web.xml, you have written,

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>

So you can access your page by not index.jsp but index.faces

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号