使用 JSF 中的 POST 请求导航到其他页面

Navigate to other page using POST request in JSF

在 JSF 中,我正在执行如下 GET 请求:

<p:button value="Select Document" icon="fa fa-save" outcome="index">
    <f:param name="documento"
             value="#{dIGRCController.digrc.selectedDigrc.documento}" />
</p:button>

我不想在 URL 中显示该值,所以我尝试发出 POST 请求。我怎样才能做到这一点?

在我的项目中,我使用 PrimeFaces 5.3、JSF 2.2 和 OmniFaces 1.11。

使用 commandButton 而不是 button

POST 完全等同于您的 GET 代码段如下:

<h:form>
    <p:commandButton value="Select Document" icon="fa fa-save" action="index">
        <f:param name="documento"
                 value="#{dIGRCController.digrc.selectedDigrc.documento}" />
    </p:commandButton>
</h:form>

您只需要记住 URL 更改不会反映在地址栏中,并且目标页面不再可收藏。如果目标页面不是幂等的,这应该不是问题,但它看起来不像是一个(“SELECT”总是幂等的)。

另请参阅: