第一种方法:使用ModelAndView
public ModelAndView index(HttpServletRequest request) {
ModelAndView view = new ModelAndView();
String url = request.getContextPath() + "/survey.html"; //getContextPath()获得项目所在路径
return new ModelAndView(new RedirectView(url));
}
第二种方法:使用String
@RequestMapping(value="/logout.html")
public String logout(HttpServletRequest request) {
String url = "/index.html";
return "redirect:" + url;
}