Navigation IceFaces 2-导航规则有时不适用

Navigation IceFaces 2-导航规则有时不适用,navigation,icefaces,Navigation,Icefaces,我有一个小冰面项目。打开基本url localhost:8080/myContextPath将打开一个名为index.jsp的文件,其中包含以下内容: <html> <head> </head> <body> <jsp:forward page="faces/search.xhtml" /> </body> </html> 这首先重定向到faces/search.xhtml。这一页的显示没有

我有一个小冰面项目。打开基本url localhost:8080/myContextPath将打开一个名为index.jsp的文件,其中包含以下内容:

<html>
  <head> </head>
  <body>
    <jsp:forward page="faces/search.xhtml" />
  </body>
</html>
这首先重定向到faces/search.xhtml。这一页的显示没有任何问题。浏览器地址栏按预期显示localhost:8080/myContextPath

在search.xhtml页面上有一个提交按钮,如下所示:

<h:commandButton type="submit" value="Search" id="submit" actionListener="#{searchBean.submitButton}" action="#{searchBean.navigate}" />
<navigation-rule>
  <from-view-id>/search.xhtml</from-view-id>
  <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/search.xhtml</to-view-id>
  </navigation-case>
</navigation-rule>
单击该按钮会触发actionListener,然后触发navigate操作,返回一个简单的成功

导航规则本身如下所示:

<h:commandButton type="submit" value="Search" id="submit" actionListener="#{searchBean.submitButton}" action="#{searchBean.navigate}" />
<navigation-rule>
  <from-view-id>/search.xhtml</from-view-id>
  <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/search.xhtml</to-view-id>
  </navigation-case>
</navigation-rule>
据我所知,导航规则在任何情况下都应适用

可悲的是,有时这不起作用。准确地说,每秒钟它都不起作用。单击submit按钮首先触发action listener,然后webapp思考大约1-2秒,然后重定向到一个断开的页面

与正常方式的区别

localhost:8080/myContextPath->单击提交按钮->localhost:8080/myContextPath

坏的情况是,地址栏上看起来像这样

localhost:8080/myContextPath->单击提交按钮->localhost:8080/myContextPath/faces/search.xhtml

然后页面被破坏,导致无法再找到所有javascript和css文件,因为它们被相对路径引用

您知道哪些问题会导致导航中断吗

简而言之:首次加载页面是index.jsp页面中的一个简单重定向:index.jsp->jsp:formward->search.xhtml。然后单击submit按钮,导航规则重新加载search.xhtml。现在我第二次按下提交按钮,现在导航规则不再工作。而是将地址栏中的url更改为localhost:8080//faces/search.xhtml,而不是保留在localhost:8080/

致意
Tobias

当您执行此操作时,实际发生的是您正在执行服务器端转发,而不是客户端重定向,这就是为什么尽管您的地址栏显示myContextPath 它已经在faces/search.xhtml下

<jsp:forward page="faces/search.xhtml" />
基本上,当您单击导航时,将规则从/search.xhtml更改为/faces/search.xhtml

<jsp:forward page="faces/search.xhtml" />