Spring 3.0 forwarding request to different controller

后端 未结 3 432
广开言路
广开言路 2021-01-31 17:44

What is the proper way to forward a request in spring to a different controller?

@RequestMapping({\"/someurl\"})
public ModelAndView execute(Model model) {
    i         


        
3条回答
  •  遇见更好的自我
    2021-01-31 17:54

    You can use view name like "redirect:controllerName" or "forward:controllerName". The latter will reroute request to another controller and former will tell browser to redirect request to another url.

    docs: https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-redirecting-redirect-prefix

提交回复
热议问题