ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
String basePath = servletContext.getContextPath();
mv.setView(new RedirectView(basePath+"/main"));
org.springframework.web.context.ContextLoader 对象
org.springframework.web.servlet.view.RedirectView 对象
本文介绍了一个使用 Spring MVC 进行页面重定向的例子。通过获取 ServletContext 对象并设置基础路径,最终实现了向指定页面的跳转。此过程涉及 ContextLoader 与 RedirectView 的使用。


被折叠的 条评论
为什么被折叠?



