简体   繁体   English

Struts 1从操作重定向到参数作为POST请求的操作

[英]Struts 1 redirect from action to action with parameters as POST request

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请求参数(隐藏参数)

You can't, it is not a Struts problem. 您不能,这不是Struts问题。 It is how HTTP is designed. 这是HTTP的设计方式。 When a browser is redirected, it perform a GET request. 重定向浏览器时,它会执行GET请求。 You cannot ask the browser to do a POST instead. 您不能要求浏览器执行POST The only way would be to add some Javascript to send the request. 唯一的方法是添加一些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不会更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM