💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
![](https://box.kancloud.cn/cc8c2bfea6a27384f56b5f870b718e2f_539x109.png) jstl/jstl.jsp ~~~ <%@ page import="zyw.bean.User" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.List" %><%-- Created by IntelliJ IDEA. User: Administrator Date: 2018/7/14 Time: 16:08 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title>Title</title> </head> <body> <%--使用JSTL的时候需要配合EL表达式--%> <c:if test="${requestScope.follow eq 1}"> 取消关注 <%--如果test等于true 则会执行内部代码,如果是false则不会执行内部代码--%> </c:if> <c:if test="${requestScope.follow eq 0}"> 关注 <%--如果test等于true 则会执行内部代码,如果是false则不会执行内部代码--%> </c:if> <% List<User> list=new ArrayList<>(); User user1=new User(); user1.setName("小强"); user1.setSex("男"); User user2=new User(); user2.setName("小丽"); user2.setSex("女"); list.add(user1); list.add(user2); for (int i = 0; i < list.size(); i++) { System.out.println(i); } request.setAttribute("list",list); for (User user : list) { System.out.println(user.getName()); } %> <c:forEach begin="0" end="${list.size()-1}" var="i"> ${list[i].name} </c:forEach> <%--items代表的是一个集合或者是数组--%> <c:forEach items="${list}" var="user"> ${user.name} </c:forEach> </body> </html> ~~~ ![](https://box.kancloud.cn/27ecb47b0fe9aeb286075902e1e710cc_565x141.png)