java Struts 1 从动作重定向到动作,参数为 POST 请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17103749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 00:59:38  来源:igfitidea点击:

Struts 1 redirect from action to action with parameters as POST request

javapoststruts

提问by rpandidurai

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

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

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;

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

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

回答by gma

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

你不能,这不是 Struts 的问题。这就是 HTTP 的设计方式。当浏览器被重定向时,它会执行一个GET请求。您不能要求浏览器执行 aPOST来代替。唯一的方法是添加一些 Javascript 来发送请求。

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 做一个内部重定向,但它对客户端是隐藏的,url 不会改变。