Spring MVC- Redirect from one controller to another

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

  1. What is springcontroller1.abc is all about (abc?)

    ReplyDelete
  2. Thanks for your great information, the contents are quiet interesting.I will be waiting for your next post.
    Window Ac Repairing Service in Delhi NCR


    ReplyDelete
  3. This was a useful post and I think it's fairly easy to see in the other reviews, so this post is well written and useful. Keep up the good work.
    Building Contractors Service Provider In Delhi NCR

    ReplyDelete
  4. This turned into a beneficial post and I suppose it is fairly clean to see inside the other opinions, so this put up is properly written and useful. Keep up the good work buy persuasive essay in uk

    ReplyDelete
  5. This is such a great resource that you are providing and you it away for free. I love seeing blog that understand the value.
    Event Organizers in South Delhi
    Event Organizers in Delhi NCR

    ReplyDelete

Post a Comment

Popular posts from this blog

defining functions clojure

Integrating Struts2 with Spring Security using Custom Login Form