用EL表达式获取List>里面的值

<%@ page language="Java" pageEncoding="UTF-8" import="java.util.*" %>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">    
<html:html lang="true">    
  <head>    
    <html:base />    

    <title>MyJsp.jsp</title>
    <meta http-equiv="pragma" content="no-cache">   
    <meta http-equiv="cache-control" content="no-cache">    
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    
    <meta http-equiv="description" content="This is my page">    
    <!-- <link rel="stylesheet" type="text/css" href="styles.css"> -->
  </head>
<!-- 测试用数据,一般通过request.attribute跳转过来-->   
<% List<Map<String,Object>> students = new ArrayList<Map<String,Object>>(); Map<String,Object> s1 = new HashMap<String,Object>(); s1.put("name","jim"); s1.put("age","15"); students.add(s1); Map<String,Object> s2 = new HashMap<String,Object>(); s2.put("name","lucy"); s2.put("age","12"); students.add(s2); request.setAttribute("students",students); %>  
  <body>     
    <table>    
       <tr>    
        <td>姓名    
        </td>    
        <td>年龄    
        </td>    
       </tr>    
       <!-- loop begin -->    
       <c:forEach var="student" items="${students}" >       
          <tr>        
          <td> <c:out value="${student.name}" default="wang"/>        
          </td>        

          <td>        
           <c:out value="${student.age}" default="wang"/>        
          </td>        
          </tr>        
       </c:forEach>
       <!-- loop end -->    
    </table>    
  </body>    
</html:html>

你可能感兴趣的:(jsp,map)