Struts 1使用POST请求作为参数从一个动作重定向到另一个动作 [英] Struts 1 redirect from action to action with parameters as POST request

查看:458
本文介绍了Struts 1使用POST请求作为参数从一个动作重定向到另一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在尝试在Struts 1.3 Web应用程序中使用某些参数从动作类重定向到动作类, 这是我的代码

now am trying to redirect to action class from action class with some parameters in my Struts 1.3 web application, here is my code

ActionRedirect redirect = new ActionRedirect(mapping.findForward(forwardPage));
redirect.addParameter("method", forwardPage);   
redirect.addParameter("username", "user");
redirect.addParameter("password", "PWD");
redirect.addParameter("forwardPage", "success");        
return redirect;

它工作正常,但是所有参数都显示在地址栏中,我如何将其重定向为POST请求参数(隐藏参数)

it's working fine, but all parameters are showed in address bar, how can i redirect it as POST request parameter(hide parameters)

推荐答案

您不能,这不是Struts问题.这就是HTTP的设计方式.重定向浏览器后,它将执行GET请求.您不能要求浏览器执行POST.唯一的方法是添加一些Javascript来发送请求.

You can't, it is not a Struts problem. It is how HTTP is designed. When a browser is redirected, it perform a GET request. You cannot ask the browser to do a POST instead. The only way would be to add some Javascript to send the request.

或者您也可以要求Struts进行内部重定向,但是它将对客户端隐藏并且URL不会更改.

Or you can also ask Struts to do an internal redirection but it will be hidden to the client and the url will not change.

这篇关于Struts 1使用POST请求作为参数从一个动作重定向到另一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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