JSF:重定向到url而不是GET

编程入门 行业动态 更新时间:2024-10-24 23:15:11
本文介绍了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

本文发布于:2023-10-10 22:40:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   重定向   JSF   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!