SpringMVC返回ModelAndView
在使用SpringMVC时,如果既要返回JSP页面又要返回值,可以return ModelAndView
具体示例如下:
@RequestMapping("/info.do")
public ModelAndView info(HttpServletRequest request,ModelMap model){
String id = CookieUtil.getCookieValue(request,"studentId");
//System.out.println(id);
//用户未登陆
if(id==null || id==""){
//studentId的cookie不存在,去登陆页面
return new ModelAndView("redirect:toLogin.do");
}
//加载用户详细信息,返回
Student student = studentService.l