zoukankan      html  css  js  c++  java
  • jstl+el表达式示例代码

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@page import="cn.itcast.Person"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>jstl+el表达式示例代码</title>
      </head>
      
      <body>
        
        
        <!-- 使用jstl+el表达式可以迭代list集合 -->
        <% 
            Person p1 = new Person();
            p1.setName("aa111");
            
            Person p2 = new Person();
            p2.setName("bb");
            
            List list = new ArrayList();
            list.add(p1);
            list.add(p2);
            
            request.setAttribute("list",list);
        %>
        
        <c:forEach var="person" items="${list}">
            ${person.name }<br/>
        </c:forEach>
        
        
        <!-- 使用jstl+el表达式可以迭代map集合 -->
        <% 
            Map map = new HashMap();
            map.put("a","aaaaxxx");
            map.put("b","bbbb");
            map.put("c","cccc");
            map.put("1","aaaa1111");
            
            request.setAttribute("map",map);
        %>
        
        <br/>
        
           <%-- Set<Map.Entry> set = map.entrySet()--%>
        <c:forEach var="me" items="${map}">  
            ${me.key } = ${me.value }<br/>
        </c:forEach>
        
        
        <br/><br/>
        
        <c:if test="${user!=null}">
            欢迎您:${user.uesrname }
        </c:if>
        
         <c:if test="${user==null}">
            用户名:<input type="text" name="username">
            密码:<input type="password" name="password">
            <input type="submit" value="登陆">
        </c:if>
        
        
        
      </body>
    </html>
  • 相关阅读:
    0125——时钟
    0125——动画2
    0124——动画1
    0124——KVC KVO模式
    0123——单例模式
    0122——简单小动画+微博简单模拟2
    0122——UITabBarController
    0119——UIImageView的一些属性 和 简单动画实现
    12月28号 ios设计简单操作
    12月25号 Category类别
  • 原文地址:https://www.cnblogs.com/lichone2010/p/3130134.html
Copyright © 2011-2022 走看看