1
<html xmlns:h="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui">

<o:form includeViewParams="true">
  <h:commandButton value="Home" action="/index?faces-redirect=true"/>
  <p:dataTable> 

  </p:dataTable>
</o:form>

h:commandButton 在 o:form 下不起作用。当我单击它时,它仍然在同一页面上。但是当我更改为 h:form 时,它可以工作。不过,我需要为 includeViewParams 使用 o:form。有什么办法可以解决这个问题吗?

4

1 回答 1

4

这个结构对我有用,因为它实际上导航到/index. 只有视图参数从 URL 中消失,因为您正在强制重定向。但还有更多,<h:commandButton>这里本质上是错误的工具。您想要纯页面到页面导航。然后,您根本不应该使用命令链接/按钮,而是使用普通链接/按钮。你需要<h:button>.

<h:button value="Home" outcome="/index" includeViewParams="true" />

注意:这不需要任何形式。

也可以看看:

于 2013-10-21T09:41:09.790 回答