JSF:重定向到url而不是GET [英] JSF: Redirect to url as POST not as GET

查看:157
本文介绍了JSF:重定向到url而不是GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆