I want to redirect to another page(outside my application) from spring controller with post parameter. I search a lot but didn't any solution.
You will not be able to add a POST, but you can redirect with GET. Do the following:
@RequestMapping("/redirectMe")
public void redirectMe (HttpServletResponse response){
response.sendRedirect("http://redirected.com/form?someGetParam=foo");
}
Do something like this
@RequestMapping(value="/someUrl",method=RequestMethod.POST)
public String myFunc(HttpServletRequest request,HttpServletResponse response,Map model){
//do sume stuffs
return "redirect:/anotherUrl"; //gets redirected to the url '/anotherUrl'
}
@RequestMapping(value="/anotherUrl",method=RequestMethod.GET)
public String myAnotherFunc(HttpServletRequest request,HttpServletResponse response){
//do sume stuffs
return "someView";
}
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