How to redirect to another site in Spring MVC JavaEE

I was looking for time to search, and I could not find a clear answer or documentation on this particular method.

I want to redirect to another site, for example stackoverflow.com, using this method ... But I do not know how to do this. Any help would be appreciated.

@RequestMapping(value = "/redirectTravelocity", method = RequestMethod.GET) private ModelAndView processForm() { ModelAndView modelAndView = new ModelAndView( "redirect:stackoverflow.com" ); Map<String, Object> model = modelAndView.getModel(); model.put( "error", "this.is.my.error.code" ); return new ModelAndView( "redirect:stackoverflow.com", model ); } 

It does not work, it redirects to my site and it crashes ... I know this is stupid, but I do not know how to do it.

+6
source share
2 answers

Here is one way to do this:

 @RequestMapping(value = "/redirectTravelocity", method = RequestMethod.GET) private String processForm() { return "redirect:http://stackoverflow.com"; } 
+6
source

change redirect:stackoverflow.com to redirect:http://stackoverflow.com

0
source

All Articles