我只是从 Mojarra 切换到 Myfaces。大多不是太麻烦,但导航规则不像以前那样工作。我在导航案例中遇到重定向问题:
<navigation-case>
<from-outcome>test.edit</from-outcome>
<to-view-id>/test.xhtml</to-view-id>
<redirect/>
</navigation-case>
如下所示的任何命令链接导航都会导致 403 错误(拒绝访问):
<h:commandLink value="Add" id="test" action="test.edit"/>
在这种特殊情况下,浏览器尝试重定向到 test.xhtml(而不是 test.jsf)。web.xml 中的安全约束阻止了这一点。当然,如果您删除安全约束,您将提供原始 xhtml。
如果我删除重定向它工作得很好,但当然不会改变浏览器网址。
此外,我曾经能够对无效结果进行导航,例如:
<navigation-rule>
<from-view-id>/test.xhtml</from-view-id>
<navigation-case>
<from-action>#{bean.save}</from-action>
<if>#{true}</if>
<to-view-id>/list.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
但是,当发送 ajax 请求以动态显示列表(不调用 bean.save 方法)时,页面将被重定向。