问题描述
我有一个接受用户名和密码的简单表单.如果登录有效,我必须使用 sendRedirect()
方法使页面重定向到一个页面,如果登录有效,则重定向到另一个页面.我需要使用 sendRedirect()
而不是 forward()
因为其他页面位于另一个服务器中.我注意到当使用
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));
sendRedirect()
正在使用 GET
方法,因为 name=value 显示在 URL 中.这对我来说是不可取的,因为出于安全原因,我不希望这些值显示在 URL 中.
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.
有没有办法使用 sendRedirect() POST
这些值?我尝试使用 POST
方法创建一个表单,该方法隐藏了我需要的值,但仍然没有运气
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 :)
推荐答案
不,这不可能.我看到的唯一(脏)解决方法是转发到包含隐藏表单(使用 POST 方法)和提交此表单的 JavaScript 脚本的内部页面.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!