springmvc里HttpServletRequest和model的区别
@RequestMapping(value="/list",method=RequestMethod.GET)
public String list(Model model) { //前台输出必须使用形如${ul.value.id }的形式
model.addAttribute("userList",userList);
return "user/userList";
}
@RequestMapping(value="/userlist",method=RequestMethod.GET)
public String list(HttpServletRequest request) { //前台输出必须使用形如${user.id }的形式
List userList = new ArrayList();
userList.add(new User("1","yonghu1","121","1@qq.com"));
userList.add(new User("2","yonghu2","122","2@qq.com"));
userList.add(new User("3","yonghu3","123","3@qq.com"));
request.setAttribute("userList", userList);
return "user/userList";
}
为什么前台取值时得使用不同的方法呢?HttpServletRequest和model不都是以map键值对的形式存数据的吗? |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|