我是JSF的新手,我正在创建一个简单的jsf应用程序。当我尝试使用Tomcat运行应用程序时,我收到404错误,我不知道为什么。我尝试从eclipse运行应用程序,而不是从eclipse运行,但都不起作用。我尝试过多个不同的url(所有区分大小写),包括localhost:8080 / testing / faces / index.jsp,localhost:8080 / testing / index.jsp,localhost:8080 / testing /,但都不起作用。据我所知,我的文件都在正确的位置(我的jsp文件在WebContent下,我的web.xml和我的faces-config在WEB-INF中)。有谁知道我的代码有什么问题?我已经粘贴了我的web.xml和下面的faces-config。
的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_3_0.xsd" version="3.0">
<display-name>testing</display-name>
<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>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF
Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'
</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>faces/index.jsp</welcome-file>
<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_2_1.xsd"
version="2.1">
<managed-bean>
<managed-bean-name>results</managed-bean-name>
<managed-bean-class>testing.model.Results</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>tuple</managed-bean-name>
<managed-bean-class>testing.model.Tuple</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>WEB-INF/index</display-name>
<from-view-id>/WEB-INF/index.jsp</from-view-id>
<navigation-case>
<from-outcome>true</from-outcome>
<to-view-id>/WEB-INF/newValsIndex.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>WEB-INF/index</display-name>
<from-view-id>/WEB-INF/index.jsp</from-view-id>
<navigation-case>
<from-outcome>false</from-outcome>
<to-view-id>/WEB-INF/failedLogin.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
非常感谢!