"返回新的ModelAndView("redirect:surveys.html")之间的区别是什么;" 并"返回新的ModelAndView("surveys.html");"

use*_*355 7 model-view-controller spring modelandview

问题出在标题中.我有一个Spring MVC网络应用程序,我必须修改很多东西,我对此没有任何想法,在做任何事情之前我都想了解它是如何制作的.

有什么区别:

return new ModelAndView("redirect:surveys.hmtl");
Run Code Online (Sandbox Code Playgroud)

return new ModelAndView("surveys.html");
Run Code Online (Sandbox Code Playgroud)

谢谢.

JB *_*zet 12

第一个重定向:

                  POST or GET
browser -------------------------------------> spring controller

         redirect to surveys.html (status = 302)
        <------------------------------------

                  GET
        -------------------------------------> surveys.html

                  final page
        <-------------------------------------
Run Code Online (Sandbox Code Playgroud)

第二个转发:

                    POST or GET
browser -------------------------------------> spring controller
                                                     |
                                                     |
                    final page                       V
        <------------------------------------- surveys.html
Run Code Online (Sandbox Code Playgroud)