sendRedirect()可以作为post方法而不是get? - jsp / servlets [英] Can sendRedirect() act as a post method instead of get? - jsp/servlets

查看:116
本文介绍了sendRedirect()可以作为post方法而不是get? - jsp / servlets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个接受用户名和密码的简单表单。如果登录有效,则必须使用 sendRedirect()方法将页面重定向到一个页面,否则使用另一个页面。我需要使用 sendRedirect()而不是 forward(),因为其他页面位于另一个服务器中。我注意到,当使用

  response.sendRedirect(response.encodeRedirectURL(FileName.jsp?paramName =+ value)); 

sendRedirect()正在使用 GET 方法,因为名称=值正显示在URL中。这对我来说是不可取的,因为我不希望这些值出于安全原因显示在URL中。

有没有办法通过sendRedirect()来使用 POST 这些值?
我尝试使用方法 POST 来完成一个表单,该方法隐藏了我需要的值,但仍然没有运气



我能做些什么吗?感谢:)

解决方案

不,这是不可能的。我看到的唯一(肮脏)解决方法是转发到包含隐藏表单(使用方法POST)和提交此表单的JavaScript脚本的内部页面。


I have a simple form which accepts a username and a password. I have to use sendRedirect() method for the page to redirect to one page if log in is valid and to another if not. I need to use sendRedirect() and not forward() since the other pages are located in another server. I noticed that when using

response.sendRedirect(response.encodeRedirectURL("FileName.jsp?paramName=" +value));

the sendRedirect() is using the GET method since name=value are being shown in the URL. This is not desirable for me since I don't want these values to show in the URL for safety reasons.

Is there a way to POST these values using sendRedirect() ? I tried to do a form with method POST which hides the values I need but still no luck

What can I do please? Thanks :)

解决方案

No, it's not possible. The only (dirty) workaround I see is to forward to an internal page containing a hidden form (with method POST) and a JavaScript script submitting this form.

这篇关于sendRedirect()可以作为post方法而不是get? - jsp / servlets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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