-->

Struts 1 redirect from action to action with param

2019-05-20 18:01发布

问题:

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;

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

回答1:

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.

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.



标签: java post struts