我正在开发一个Spring MVC应用程序。我有一种情况,我从弹出窗口提交信息。如何在控制器中编写重定向,以便我将重定向到提交弹出窗口的父页面。
从弹出窗口我将转到下面的控制器。从那里我想来到父窗口。我不知道我怎么能做到这一点。 例如:@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
}
提前致谢。
答案 0 :(得分:1)
如果您只想重定向到引荐网址,请尝试以下内容......
@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);
}
答案 1 :(得分:0)
您可以使用此示例:
@RequestMapping(Value="/home", method = {RequestMethod.POST})
public ModelAndView homepAge(@ModelAttribute("homeForm") HomeForm homeForm, BindingResult errors,
HttpServletResponse response,HttpServletRequest requst) {
return new ModelAndView("redirect:/myURL");
}