在做spring时控制类如下
@Controller
@RequestMapping("/user")
public class UserController {
private Map<String,User> users=new HashMap<String,User>();
public UserController(){
users.put("admin", new User("admin","123","管理员","123@fff.com"));
users.put("t", new User("t","123","教师一","fewqf3@fff.com"));
users.put("s", new User("s","123","学生一","fedewqe3@fff.com"));
}
@RequestMapping(value="/users",method=RequestMethod.GET)
public String list(Model model){
model.addAttribute("users", users);
System.out.println(model.toString());
return "user/list";
}
}
在user/list.jsp中用
<c:forEach items="${users}" var="um">
UserName:${um.value.username}<br/>
PWD:${um.value.password }<br/>
NickName:${um.value.nickname }<br/>
E-mail:${um.value.email }<br/>
</c:forEach>
获取不到具体变量
显示
UserName:${um.value.username}
PWD:${um.value.password }
NickName:${um.value.nickname }
E-mail:${um.value.email }
请帮助,刚开始学这个?谢谢
------解决思路----------------------
${um} 看看呢?
------解决思路----------------------
调试具体看看你 的里面放的什么。
------解决思路----------------------
你的user里面的属性是username吗
------解决思路----------------------
你这el表达式都没起作用,你检查下你jsp上面是否启用el表达式
------解决思路----------------------
看看web.xml是否web2.5,2.5是默认忽略el表达式的,可以换成web2.4