How to make a controller method to redirect to other site with a post request?
@RequestMapping("/link)
public RedirectView goToTheSite(ModelMap model) {
model.put("name", "wow");
return new RedirectView("https://www.thesite.com", true, false, false);
}
but, this is not working, How to do that in right way?
How to make a controller method to redirect to other site with a post request?
Redirect means you telling browser to make a GET request, There is no out of the box feature in Spring MVC to make POST request from controller.
How to do that in right way?
Use Apache HTTP client:
Request.Post("https://www.thesite.com/login")
.bodyForm(Form.form().add("username", "vip").add("password", "secret").build())
.execute().returnContent();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With