【问题标题】:use for each value in jsp tag用于 jsp 标记中的每个值
【发布时间】:2018-06-14 10:59:45
【问题描述】:

我在 jsp 页面的迭代中有一个 foreach 值,如图所示

<c:forEach var="lists" items="${lists}" varStatus="theCount">

String val=   ${lists.getVal() } ; //this is giving me error


</c:forEach>

【问题讨论】:

  • String val= ${lists.getVal() } ; //this is giving me error 是什么意思。你到底想做什么?
  • 将这个值 lists.getVal() 分配给我正在尝试的字符串

标签: java jsp foreach


【解决方案1】:

https://www.tutorialspoint.com/jsp/jstl_core_set_tag.htm

<c:forEach var="list" items="${lists}" varStatus="theCount">
   <c:set var="val" value="${list.val}"/>
   <p>The value is: ${val}.</p>
</c:forEach>

【讨论】:

  • 我想把它赋值给jsp页面上的一个字符串
  • 我想也许你需要去阅读一些基础知识。
  • 这一行不正确&lt;c:set var="val" value="list.val"/&gt;应该是&lt;c:set var="val" value="${list.val}"/&gt;
  • 因为否则你会在&lt;p&gt; 标签中看到这个The value is: list.val
  • 是的,当然。已更新。
猜你喜欢
  • 1970-01-01
  • 2015-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-27
  • 1970-01-01
  • 2012-10-24
  • 2013-06-10
相关资源
最近更新 更多