• 使用jstl和el表达式来展示request域中存放的user对象的信息


    <%@ page import="java.util.ArrayList" %>
    <%@ page import="java.util.List" %>
    <%@ page import="com.hopetesting.domain.User" %>
    <%@ page import="java.util.Date" %>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <html>
    <head>
    <title>jstl案例</title>
    </head>
    <body>
    <%
    List list = new ArrayList();
    list.add(new User("zmy", 10, new Date()));
    list.add(new User("light", 13, new Date()));
    list.add(new User("newcityboy", 15, new Date()));
    request.setAttribute("list", list);
    %>


    <table border="1px solid pink" width="97%" align="center">
    <tr>
    <th>序号</th>
    <th>姓名</th>
    <th>年龄</th>
    <th>生日</th>
    </tr>
    <c:forEach items="${list}" var="user" varStatus="s">
    <c:if test="${s.count%2==0}">
    <tr bgcolor="#7fffd4">
    <td>${s.count}</td>
    <td>${user.name}</td>
    <td>${user.age}</td>
    <td>${user.birStr}</td>
    </tr>
    </c:if>

    <c:if test="${s.count%2!=0}">
    <tr bgcolor="#f08080">
    <td>${s.count}</td>
    <td>${user.name}</td>
    <td>${user.age}</td>
    <td>${user.birStr}</td>
    </tr>
    </c:if>
    </c:forEach>
    </table>

    </body>
    </html>


  • 相关阅读:
    研究生
    linux下C++开发工具
    GCC and G++ install
    linux yum命令详解
    OpenCV:SURF算法浅析
    linux内核(kernel)版本号的意义
    常见排序算法
    bash:command not found
    C++ 面向对象(数据封装)
    HTML5 script 标签的 crossorigin 和integrity属性的作用
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11479001.html
Copyright © 2020-2023  润新知