获取 JSF 2 url 在第一次而不是第二次单击后更改

发布于 2024-12-26 12:13:03 字数 219 浏览 1 评论 0原文

JSF URL 似乎在第一次点击后没有改变,只有在第二次点击后才改变。例如,当从 home.jsf 导航到 auction.jsf 时,显示的页面已经是 auction.jsf 但浏览器地址栏中的 URL停留在 home.jsf,直到我第二次单击拍卖链接。为什么会发生这种情况?有没有办法禁用它,并让 url 正确显示?

JSF URLs don't seem to change after the first click, only after the 2nd. E.g. when navigating from home.jsf to auction.jsf, the page being displayed is already auction.jsf but the URL in the browser address bar stays at home.jsf, until I click on the Auction link the second time. Why is this happening? Is there a way to disable it, and get the url to display correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2025-01-02 12:13:03

您似乎是通过 POST 而不是 GET 进行导航。首先,您不应该通过 POST 执行页面到页面的导航。替换 ;作者:

因此,不要导航,

<h:form>
    <h:commandLink value="Auction" action="auction" />
</h:form>

而是通过

<h:link value="Auction" outcome="auction" />

JSF POST 表单基本上提交到当前 URL,默认情况下,任何导航都是由服务器端转发使用 RequestDispatcher#forward()(如果您非常熟悉基本的Servlet API,你知道这意味着什么)。您可以通过执行重定向来解决

<h:form>
    <h:commandLink value="Auction" action="auction?faces-redirect=true" />
</h:form>

,但正如所说,这是一种解决方法,而不是解决方案。

另请参阅:

You seem to be navigating by POST instead of by GET. You should not perform page-to-page navigation by POST in first place. Replace <h:commandLink> by <h:link>.

So, do not navigate by

<h:form>
    <h:commandLink value="Auction" action="auction" />
</h:form>

but by

<h:link value="Auction" outcome="auction" />

A JSF POST form basically submits to the current URL and any navigation is by default performed by a server-side forward using RequestDispatcher#forward() (if you are well familiar with the basic Servlet API, you know what this means). You could work around with performing a redirect instead

<h:form>
    <h:commandLink value="Auction" action="auction?faces-redirect=true" />
</h:form>

but, as said, this is a work around not a solution.

See also:

口干舌燥 2025-01-02 12:13:03

您需要将 faces-redirect=true 添加到您的网址。查看来自 Mkyong 的这个简短的教程 .com。

You need to add faces-redirect=true to your URL. Check out this short tutorial from Mkyong.com.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文