In spring mvc its very easy to redirect from one controller to another controller Example : @Controller @RequestMapping("/springcontroller1") public class SpringController1{ } @Controller public class SpringController2{ //thinking of redirecting on clicking on a method @RequestMapping(value = "/SpringController2cancel.abc", method = RequestMethod.POST, params = "action=cancel") public ModelAndView cancel(@ModelAttribute("MyForm") MyForm myForm, BindingResult errors,SessionStatus sessionStatus,HttpServletRequest request) throws MyException { ModelAndView modelAndView = new ModelAndView(); sessionStatus.setComplete(); //redirecting to controller1 return new ModelAndView("redirect:/springcontroller1.abc"); } }
Comments
Post a Comment