how to use spring4 @RestController to return a jsp page?

后端 未结 5 1558
野趣味
野趣味 2020-12-10 16:59

When I use spring3 @Controller like this:

@RequestMapping(\"/userCenter\")

@Controller
public class LoginCtrl {
    @RequestMapping(\"/loginPage\")
    publ         


        
5条回答
  •  我在风中等你
    2020-12-10 17:17

    Actually,@RestController could also return view...

    After one day research and read document,I got a solution

    Let me share the solution with everyone:

    First,set the controller method's return type to be "ModelAndView"

    Second,set your view path like this

    ModelAndView mav = new ModelAndView("userCenter/loginPage");
    

    Finally

    return mav;
    

    You would get the right jsp page view content

提交回复
热议问题