我的RequestMapping& ResponseBody是这样的:
@RequestMapping(value = "/someURL", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ModelAndView getDetails(
@RequestParam(value = "param1", required = false) String param1,
@RequestParam(value = "param2", required = false) String param2,
{
现在基于param1,我想重定向到特定的URL。 例如。现在处理后,我的页面将进入
http://parent-domain/someURL?param1=...param2=...
但我想要的是像这样完全改变父域
http://some-other-domain/someURL?param1=...param2=...
答案 0 :(得分:1)
做这样的事情:
@RequestMapping(value = "/someURL", method = RequestMethod.GET, produces = "application/json")
public ModelAndView getDetails(@RequestParam(value = "param1", required = false) String param1,
@RequestParam(value = "param2", required = false) String param2) {
if (param1.equals("a"))
return new ModelAndView("redirect:somotherurl");
else
return new ModelAndView("redirect:http://google.com");
}
如果param1是a,那么它会转到其他地方的某个地方,它会重定向到google.com