title: JSF 2 form action navigation not working
body: <p>Im just testing out JSF 2 with Primefaces and are setting up a basic test-form. 
  The goal is to submit the form and then send the user to a page listing all the entries.</p>
  
  <p>But all that happens if i click "Add" button is that my webapp tries to navigate to page: "//pages/index.xhtml", and there nothing is found...</p>
  
  <p>Any ideas?? I have followed tutorials pretty much, but cant see where i got it wrong..
  I have mapped the commandbutton to the ManagedBean-method "addUser". The addUser method returns "success", and i have set up "success" to go to success.xhtml.. </p>
  
  <p>I have spent 3 hours debugging this now and i'm about to go crazy, so any help would be greatly appriciated...</p>
  
  <p>index.xhtml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"&gt;
      &lt;h:head&gt;&lt;title&gt;Welcome to OTV_JSF_Spring_Hibernate_Project&lt;/title&gt;&lt;/h:head&gt;
      &lt;h:body&gt;
          &lt;h:form&gt;
            &lt;table&gt;
                &lt;tr&gt;...&lt;/tr&gt;
                &lt;tr&gt;
                   &lt;td&gt;&lt;p:commandButton id="addUser" value="Add" action="#{userMB.addUser}" ajax="false"/&gt;&lt;/td&gt;
                   &lt;td&gt;&lt;p:commandButton id="reset" value="Reset" action="#{userMB.reset}" ajax="false"/&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/h:form&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>userMB:</p>
  
  <pre class="lang-java prettyprint-override"><code>@ManagedBean(name = "userMB")
  @RequestScoped
  public class UserManagedBean implements Serializable {
      private static final String SUCCESS = "success";
      private static final String ERROR = "error";
      /* .... */
  
      public String addUser() {
          return SUCCESS;
      }
  </code></pre>
  
  <p>faces-config.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  
  &lt;!-- JSF and Spring are integrated --&gt;
  &lt;application&gt;
      &lt;el-resolver&gt;
          org.springframework.web.jsf.el.SpringBeanFacesELResolver
      &lt;/el-resolver&gt;
  &lt;/application&gt;
  
  &lt;!-- configuration of navigation rules --&gt;
  &lt;navigation-rule&gt;
      &lt;from-view-id&gt;/pages/index.xhtml&lt;/from-view-id&gt;
      &lt;navigation-case&gt;
          &lt;from-outcome&gt;success&lt;/from-outcome&gt;
          &lt;to-view-id&gt;/pages/success.xhtml&lt;/to-view-id&gt;
      &lt;/navigation-case&gt;
      &lt;navigation-case&gt;
          &lt;from-outcome&gt;error&lt;/from-outcome&gt;
          &lt;to-view-id&gt;/pages/error.xhtml&lt;/to-view-id&gt;
      &lt;/navigation-case&gt;
  &lt;/navigation-rule&gt;
  
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>Web.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"
       id="WebApp_ID"
       version="2.5"&gt;
  
  &lt;display-name&gt;OTV_JSF_PrimeFaces_Spring_Hibernate&lt;/display-name&gt;
  
  &lt;!-- Spring Context Configuration' s Path definition --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/applicationContext.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- The Bootstrap listener to start up and shut down Spring's root WebApplicationContext. It is registered to Servlet Container --&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.ContextLoaderListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.request.RequestContextListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- Project Stage Level --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
      &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Welcome Page --&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;/pages/index.xhtml&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;!-- JSF Servlet is defined to container --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;!-- Mapping with servlet and url for the http requests. --&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.faces&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6WC2L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6WC2L.png" alt="Generated HTML"></a></p>