spring MVC 中的model、modelMap、request、session

阅读更多
Model model,HttpServletRequest request, ModelMap map声明变量

request.getSession().setAttribute("test", "haiwei2Session");
request.setAttribute("test", "haiwei1request");
map.addAttribute("test", "haiweiModelMap");
model.addAttribute("test", "haiweiModel");

我通过${test}这个方式取值,优先取Model和ModelMap的,Model和ModelMap是同一个东西,谁最后赋值的就取谁的,然后是request,最后是从session中获取
假如想直接取request.getParameter("test"),则用${param.test}

你可能感兴趣的:(MVC,Spring)