单击按钮(JSF)时无法导航到下一页

单击按钮(JSF)时无法导航到下一页,jsf,commandbutton,Jsf,Commandbutton,我目前正在学习jsf。我编写了一个简单的jsf应用程序,目标是从一个页面导航到另一个页面。但是,我根本无法导航 在我的代码中有两个jsp文件;一个是createcustomer.jsp,另一个是viewCustomerDetails。在用户在createcustomer.jsp中输入数据并单击按钮后,它将移动到下一页(在该页的上一页中显示输入的数据) 下面是我的代码。有人能找到我哪里出了问题吗? 查看客户详细信息 /viewCustomerDetails.jsp web.xml <fac

我目前正在学习jsf。我编写了一个简单的jsf应用程序,目标是从一个页面导航到另一个页面。但是,我根本无法导航

在我的代码中有两个jsp文件;一个是
createcustomer.jsp
,另一个是
viewCustomerDetails
。在用户在
createcustomer.jsp
中输入数据并单击按钮后,它将移动到下一页(在该页的上一页中显示输入的数据)

下面是我的代码。有人能找到我哪里出了问题吗? 查看客户详细信息 /viewCustomerDetails.jsp
web.xml

<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_0.xsd"
    version="2.0">

   <managed-bean>
   <managed-bean-name>customer</managed-bean-name>
   <managed-bean-class>com.app.view.Customer</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

   <navigation-rule>
   <from-view-id>/createcustomer.jsp</from-view-id>
   <navigation-case>
    <!--  <from-action>#{customer.validate}</from-action>  --> 
   <from-outcome>viewCustomerDetails</from-outcome>
   <to-view-id>/viewCustomerDetails.jsp</to-view-id>
   </navigation-case>

</navigation-rule>

</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_3_0.xsd" version="3.0">
  <display-name>Customer</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>
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
</web-app>

顾客
Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
/面孔/*
javax.servlet.jsp.jstl.fmt.localizationContext
资源.应用
状态保存方法:“客户端”或“服务器”(=默认值)。参见JSF规范2.5.2
javax.faces.STATE_保存方法
客户
此参数告诉MyFaces是否应允许使用javascript代码
呈现的HTML输出。
如果允许使用javascript,则命令链接锚定将具有javascript代码
提交相应的表格。
如果不允许使用javascript,则保存信息和嵌套参数的状态
将作为url参数添加。
默认值为“true”
org.apache.myfaces.ALLOW_JAVASCRIPT
真的
如果为true,则将格式化呈现的HTML代码,使其“可读”
i、 e.将写入额外的行分隔符和空格,但不会
影响HTML代码。
默认值为“true”
org.apache.myfaces.PRETTY_HTML
真的
org.apache.myfaces.DETECT\u JAVASCRIPT
假的
如果为true,则将呈现一个能够恢复
前垂直滚动每个请求。方便的功能,如果你有网页
对于长列表,您不希望浏览器页面总是跳转到顶部
如果您触发的链接或按钮操作保持在同一页面上。
默认值为“false”
org.apache.myfaces.AUTO_滚动
真的
org.apache.myfaces.webapp.StartupServletContextListener

显然,根据您的代码片段,您没有定义
标记。像
这样的组件需要在一个内部定义才能正常工作。将
的内容封装在
中,然后重试。

您面临哪些问题?还值得一提的是,您是如何定义您的web.xml.iam的。单击“创建”按钮时,不会出现任何问题,也不会提交页面customer@developer:您的问题已在进一步的第1点中得到了回答,我想指出,自从3年多前JSF2.0以来,JSP已被弃用。而且,由于JSF2.0的隐式导航特性,faces配置中的导航规则已经过时。也许您正在阅读一些糟糕或过时的JSF书籍/教程/资源。请确保您根据正确和最新的资源学习JSF,否则它只会导致头痛和灾难。从这里开始:既然您提到您正在学习使用JSF,您知道如何使用Facelets吗?我认为这值得一看,注意这只是为了帮助你(与问题没有直接关系)。Facelets完全支持JSF2.0,而JSP不支持+1@Aquillo。我强烈建议使用Facelets、JSF 2.2、CDI和所有最新的Java EE设备。当添加标记时,我会收到未知标记@developer:Dump该JSF 1.x book/tutorial/resource的警告,并寻找JSF 2.x。我已经移动到支持JSF 2.x的新工作区,但我仍然会收到与上面相同的警告。请建议我解决这个问题
<?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>Customer</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>
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
</web-app>