jsf一次又一次导航到同一页面

时间:2012-08-31 13:44:07

标签: java jsf-1.2

我的观点:

<h:commandLink  action="#{Test.action}" target="_self">test</h:commandLink>  
<h:commandLink  action="#{Test1.action}" target="_self">test1</h:commandLink>

我的课程:

class Test
{
    // ...

    public String action()
    {
        return "outcome-1";
    }
}

class Test1
{
    // ...

    public String action()
    {
        return "outcome-2";
    }
}

第1步:从1.jsp导航到2.jsp

  

18:36:14,371 INFO [STDOUT] START PHASE UPDATE_MODEL_VALUES 4
  18:36:14,371 INFO [STDOUT] /pages/1.jsp
  18:36:14,371 INFO [STDOUT] END PHASE UPDATE_MODEL_VALUES 4
  18:36:14,371 INFO [STDOUT] /pages/1.jsp
  18:36:14,371 INFO [STDOUT] START PHASE INVOKE_APPLICATION 5
  18:36:14,371 INFO [STDOUT] /pages/1.jsp
  18:36:14,371 INFO [STDOUT] END PHASE INVOKE_APPLICATION 5
  18:36:14,371 INFO [STDOUT] /pages/2.jsp
  18:36:14,371 INFO [STDOUT] START PHEND RENDER_RESPONSE 6
  18:36:14,371 INFO [STDOUT] /pages/2.jsp
  18:36:14,464 INFO [STDOUT] END PHEND RENDER_RESPONSE 6
  18:36:14,464 INFO [STDOUT] /pages/2.jsp

第2步:从2.jsp导航到3.jsp

  

18:36:55,368 INFO [STDOUT] START PHASE UPDATE_MODEL_VALUES 4
  18:36:55,368 INFO [STDOUT] /pages/2.jsp
  18:36:55,368 INFO [STDOUT] END PHASE UPDATE_MODEL_VALUES 4
  18:36:55,368 INFO [STDOUT] /pages/2.jsp
  18:36:55,368 INFO [STDOUT] START PHASE INVOKE_APPLICATION 5
  18:36:55,368 INFO [STDOUT] /pages/2.jsp
  18:36:55,368 INFO [STDOUT] END PHASE INVOKE_APPLICATION 5
  18:36:55,368 INFO [STDOUT] /pages/3.jsp
  18:36:55,368 INFO [STDOUT] START PHEND RENDER_RESPONSE 6
  18:36:55,368 INFO [STDOUT] /pages/3.jsp
  18:36:56,164 INFO [STDOUT] END PHEND RENDER_RESPONSE 6
  18:36:56,164 INFO [STDOUT] /pages/3.jsp

第3步:从3.jsp导航到2.jsp

  

18:39:09,575 INFO [STDOUT] END PHASE UPDATE_MODEL_VALUES 4
  18:39:09,575 INFO [STDOUT] /pages/3.jsp
  18:39:09,575 INFO [STDOUT] START PHASE INVOKE_APPLICATION 5
  18:39:09,575 INFO [STDOUT] /pages/3.jsp
  18:39:09,575 INFO [STDOUT] END PHASE INVOKE_APPLICATION 5
  18:39:09,575 INFO [STDOUT] /pages/3.jsp
  18:39:09,575 INFO [STDOUT] START PHASE RENDER_RESPONSE 6
  18:39:09,575 INFO [STDOUT] /pages/3.jsp
  18:39:09,716 INFO [STDOUT] END PHEND RENDER_RESPONSE 6
  18:39:09,716 INFO [STDOUT] /pages/3.jsp

在第3步中,从3.jsp导航到2.jsp呈现3.jsp本身,但在上面的步骤1&amp; 2。

1 个答案:

答案 0 :(得分:0)

您需要在faces-config.xml中配置导航案例。 例如,如果要从1.jsp导航到2.jsp,则必须配置导航规则:

<navigation-rule>
    <from-view-id>/1.jsp</from-view-id>
    <navigation-case>
        <from-outcome>outcome-2</from-outcome>
        <to-view-id>/2.jsp</to-view-id>
    </navigation-case>
</navigation-rule>