taglib遍历foreach循环list集合
生活随笔
收集整理的這篇文章主要介紹了
taglib遍历foreach循环list集合
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
第一部導(dǎo)入jstl.jar
第二步進(jìn)行l(wèi)ist傳輸:
package com.aaa.servlet;import com.aaa.dao.IUserDAO; import com.aaa.dao.impl.UserDAOImpl;import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import java.util.Map; @WebServlet("/test") public class IsLoginServlets extends HttpServlet {@Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {req.setCharacterEncoding("UTF-8");IUserDAO userDAO = new UserDAOImpl();List<Map<String, Object>> selectAllAdmin = userDAO.selectAllAdmin();req.setAttribute("list",selectAllAdmin);req.getRequestDispatcher("/indexs.jsp").forward(req,resp);} }第三步測(cè)試:
<%--Created by IntelliJ IDEA.User: AdministratorDate: 2019/6/25Time: 8:27To 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> <table><c:forEach items="${list}" var="a"><tr><td>${a.id}</td><td>${a.admin}</td><td>${a.password}</td><td>${a.mininame}</td></tr></c:forEach> </table> </body> </html>?
轉(zhuǎn)載于:https://www.cnblogs.com/fanqiexin/p/11084962.html
總結(jié)
以上是生活随笔為你收集整理的taglib遍历foreach循环list集合的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux cat 命令
- 下一篇: linux查看占用内存最多的程序