Reputation: 237
I am working on a Spring MVC application. I have a situation where i am submitting the information from the pop up. How do i write the redirect in the controller so that i will redirect to the parent page from where the popup is submitted.
from the pop up i am going to the below controller. From there i want to come to the parent window. I am not sure how can i achieve this. For Example:
@Controller
@RequestMapping(Value="/home", method = {RequestMethod.POST})
public ModelAndView homepAge(@ModelAttribute("homeForm") HomeForm homeForm, BindingResult errors,
HttpServletResponse response,HttpServletRequest requst) {
...
return mnv; //here i want to go to the same page from where i came from
}
Thanks in advance.
Upvotes: 0
Views: 1773
Reputation: 5903
If you just want to redirect to the referring URL, try something like this...
@RequestMapping(value="/home", method = {RequestMethod.POST})
public ModelAndView homepAge(@ModelAttribute("homeForm") HomeForm homeForm, BindingResult errors,
HttpServletResponse response, HttpServletRequest request) throws IOException {
String referer = request.getHeader("referer");
return new ModelAndView("redirect:" + referer, model);
}
Upvotes: 1
Reputation: 366
you can use this example :
@RequestMapping(Value="/home", method = {RequestMethod.POST})
public ModelAndView homepAge(@ModelAttribute("homeForm") HomeForm homeForm, BindingResult errors,
HttpServletResponse response,HttpServletRequest requst) {
return new ModelAndView("redirect:/myURL");
}
Upvotes: 0