Ber*_*ice 15 post redirect jsp get
我有一个简单的表单,接受用户名和密码.sendRedirect()
如果登录有效,我必须使用页面方法重定向到一个页面,如果没有,我必须使用另一个页面.我需要使用sendRedirect()
而不是forward()
因为其他页面位于另一个服务器中.我注意到使用时
response.sendRedirect(response.encodeRedirectURL("FileName.jsp?paramName=" +value));
Run Code Online (Sandbox Code Playgroud)
的sendRedirect()
使用GET
方法,因为名称=值在URL被显示.这对我来说是不可取的,因为出于安全原因,我不希望这些值显示在URL中.
有没有办法POST
使用sendRedirect()来获取这些值?我尝试用一种POST
隐藏我需要的值的方法做一个表格,但仍然没有运气
我该怎么办?谢谢 :)
这有点老了,但在这里我成功地运行了这个:
response.setStatus(307); //this makes the redirection keep your requesting method as is.
response.addHeader("Location", "http://address.to/redirect");
Run Code Online (Sandbox Code Playgroud)
有关HTTP 307状态代码的说明,请参见http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8.
归档时间: |
|
查看次数: |
46111 次 |
最近记录: |