Spring MVC- Redirect from one controller to another

In spring mvc its very easy to redirect from one controller to another controller

Example :

public class SpringController1{

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();
        //redirecting to controller1
        return new ModelAndView("redirect:/springcontroller1.abc");




Post a Comment

Popular posts from this blog

Jquery Table Inline Edititing