JSF:重定向到 url 作为 POST 而不是 GET [英] JSF: Redirect to url as POST not as GET
问题描述
我有一个 JSF 页面,它通过 context.getExternalContext().redirect(url);
重定向,其中 url 是 sth.像 login.jsf?token=foobar
I have an JSF page that redirects via context.getExternalContext().redirect(url);
where the url is sth. like login.jsf?token=foobar
我现在想要的是通过 POST 而不是通过 GET 请求发送令牌.所以它不会出现在 url 中,这可以用 JSF 实现吗?
What I want now is to send the token via POST not via GET request. So that it doesn´t show up in the url, is this possible with JSF?
推荐答案
HTTP 无法实现,JSF 也无法实现.然而,有几种方法可以达到要求.
It's not possible with HTTP, so also not with JSF. There are however several ways to achieve the requirement.
把它放在会话范围内.在重定向页面后面的 bean 中,读取它并将其从会话范围中删除.或者,当您使用 JSF 2.0 时,请使用 flash 作用域.
Put it in the session scope. In the bean behind the redirected page, read and remove it from the session scope. Or when you're using JSF 2.0, use the flash scope.
转发到包含指向所需 URL 的 POST 表单的页面,将令牌作为隐藏的输入值,并包含一些在页面加载时执行 form.submit()
的 JS 代码.
Forward to a page containing a POST form pointing to the desired URL, having the token as hidden input value and include some JS code which does form.submit()
on page load.
这篇关于JSF:重定向到 url 作为 POST 而不是 GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!