Download After_End/MVC/target/classes/JSTL/JSTL_case.jsp from zxy0307/JavaWeb: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/zxy0307/JavaWeb/resolve/main/After_End/MVC/target/classes/JSTL/JSTL_case.jsp
- Command line
-
hf download hf://zxy0307/JavaWeb/After_End/MVC/target/classes/JSTL/JSTL_case.jsp
-
curl -L -o JSTL_case.jsp https://huggingface.co/zxy0307/JavaWeb/resolve/main/After_End/MVC/target/classes/JSTL/JSTL_case.jsp
2.01 kB
| <%@ page contentType="text/html;charset=UTF-8" language="java" %> | |
| <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
| <%@ page isELIgnored="false" %> <!-- 打开EL指令 --> | |
| <%@ page import="java.util.ArrayList" %> | |
| <%@ page import="java.util.List" %> | |
| <%@ page import="java.util.Date" %> | |
| <%@ page import="Javabean.User" %> | |
| <html> | |
| <head> | |
| <title>JSTL案例</title> | |
| </head> | |
| <body> | |
| <!-- | |
| 需求: | |
| 在request域中有一个存有User对象的List集合。需要使用jstl+el将list集合数据展示到jsp页面的表格table中 | |
| --> | |
| <% | |
| List list = new ArrayList(); | |
| list.add(new User("张三", 23, new Date())); | |
| list.add(new User("李四", 24, new Date())); | |
| list.add(new User("王五", 25, new Date())); | |
| request.setAttribute("list", list); | |
| %> | |
| <table align="center" border="1" width="50%"> | |
| <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 align="center" bgcolor="green"> | |
| <td>${ s.count }</td> | |
| <td>${ user.name }</td> | |
| <td>${ user.age }</td> | |
| <td>${ user.birthStr }</td> | |
| </tr> | |
| </c:if> | |
| <c:if test="${ s.count % 2 != 0 }"> | |
| <tr align="center" bgcolor="red"> | |
| <td>${ s.count }</td> | |
| <td>${ user.name }</td> | |
| <td>${ user.age }</td> | |
| <td>${ user.birthStr }</td> | |
| </tr> | |
| </c:if> | |
| </c:forEach> | |
| </table> | |
| </body> | |
| </html> |