我有一个通过 context.getExternalContext()。redirect(url); 来重定向的JSF页面,其中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.
转到包含POST表单的页面,指向所需的URL,将令牌作为隐藏输入值并包含一些JS代码,它在页面加载时执行 form.submit()。
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而不是GET
发布评论