栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

遍历JSP中的列表对象

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

遍历JSP中的列表对象

在学习Spring和Struts之前,你可能应该学习Java。这样的输出

org.classes.database.Employee@d9b02

Object#toString()
所有对象都从
Object
该类继承的方法的结果,该类是Java中所有类的超类。

该List子类通过在所有迭代的元素,并呼吁实现这一

toString()
那些。但是,似乎你尚未在
Employee
类中实现(重写)该方法。

你的JSTL在这里

<c:forEach items="${eList}" var="employee">    <tr>        <td>Employee ID: <c:out value="${employee.eid}"/></td>        <td>Employee Pass: <c:out value="${employee.ename}"/></td>      </tr></c:forEach>

除了你没有名为的页面,请求,会话或应用程序范围内的属性外,其他都很好

eList

你需要添加它

<% List eList = (List)session.getAttribute("empList");   request.setAttribute("eList", eList);%>

或使用属性

empList
forEach

<c:forEach items="${empList}" var="employee">    <tr>        <td>Employee ID: <c:out value="${employee.eid}"/></td>        <td>Employee Pass: <c:out value="${employee.ename}"/></td>      </tr></c:forEach>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/400533.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号