Error[8]: Undefined offset: 1, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

JSTL forEach的问题从arrayList进行迭代

您正在遍历数组元素,而不是遍历数组本身。因此,数组“ $ 0.00到$ 1,000,000.00”的元素在逗号位置分割,您将获得如上所述的单个元素。

以下是一个示例:

<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><% java.util.ArrayList list = new java.util.ArrayList(); list.add("[+++].00 to ,000,000.00"); list.add(",000,000.00 to ,000,000,000.00"); request.setAttribute("list", list);%><h1>Iterating over ArrayList</h1><ul> <c:forEach items="${list}" var="value">  <li><c:out value="${value}"/></li> </c:forEach></ul><h1>Iterating over first element of ArrayList</h1><ul> <c:forEach items="${list[0]}" var="value">  <li><c:out value="${value}"/></li> </c:forEach></ul>


)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
JSTL forEach的问题从arrayList进行迭代_随笔_内存溢出

JSTL forEach的问题从arrayList进行迭代

JSTL forEach的问题从arrayList进行迭代,第1张

JSTL forEach的问题从arrayList进行迭代

您正在遍历数组元素,而不是遍历数组本身。因此,数组“ $ 0.00到$ 1,000,000.00”的元素在逗号位置分割,您将获得如上所述的单个元素。

以下是一个示例:

<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><% java.util.ArrayList list = new java.util.ArrayList(); list.add(".00 to ,000,000.00"); list.add(",000,000.00 to ,000,000,000.00"); request.setAttribute("list", list);%><h1>Iterating over ArrayList</h1><ul> <c:forEach items="${list}" var="value">  <li><c:out value="${value}"/></li> </c:forEach></ul><h1>Iterating over first element of ArrayList</h1><ul> <c:forEach items="${list[0]}" var="value">  <li><c:out value="${value}"/></li> </c:forEach></ul>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5442213.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存