springmvc的return默认为请求转发
@Controller
@RequestMapping("test")
public class RedirectController {
@RequestMapping("t1")
public String Test(HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest, Model model){
HttpSession session = httpServletRequest.getSession();
System.out.println(session.getId());
model.addAttribute("msg","请求转发");
//默认为请求转发
return "/test";
}
@RequestMapping("t2")
public String Test2(HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest, Model model){
HttpSession session = httpServletRequest.getSession();
System.out.println(session.getId());
model.addAttribute("msg","重定向");
return "redirect:/index.jsp";
}
}