jsp 的foreach标签

<%@page import="org.apache.catalina.User"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@page import="java.util.*" %>
    
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>




Insert title here


    
    <%
        request.setAttribute("count", 10);
    
    %>
    
    
    aaaa
    
    
    
    
    
    xxxx
    
    
    
    yyyy
    
    
    
    
    ${i }
${pro.name } <% List strList = new ArrayList(); strList.add("1"); strList.add("2"); strList.add("3"); strList.add("4"); request.setAttribute("strList", strList); %>

取出strList中的数据

${str }
<% //遍历Map 的值 Map strMap = new HashMap(); strMap.put("name", "lucy"); strMap.put("age", "18"); strMap.put("addr", "beiwu"); strMap.put("email", "[email protected]"); session.setAttribute("strMap", strMap); //遍历Map中的数据 Map userMap = new HashMap(); userMap.put("user1", user1); userMap.put("user2", user2); session.putValue("userMap", userMap); %> ${entry.key }:${entry.value }

取出usermap的数据

${entry.key }:${entry.value.name }--${entry.value.password }

你可能感兴趣的:(jsp 的foreach标签)