`

jsp foreach中的索引varstatus与if 空判断

    博客分类:
  • jsp
 
阅读更多

 

在jsp中判断java传来的属性值不为空使用"${not empty varName(变量名)}"

<c:if test="${ not empty userList}

 

jsp中使用foreach时获取索引值或者根据索引操作时使用varStatus

 

<c:forEach varStatus="status" var="user" items="${userList}">
    <tr><td>${status.count}</td><td>${user.username}</td><td>${user.age}</td>
    <td>${user.birthday}</td><td><input type="button" value="修改" unique=${user.id}>
    <input type="button"    value="删除" unique=${user.id}></td></tr>
</c:forEach>

 varStatus的其他属性

${status.index}      输出行号,从0开始。

${status.count}      输出行号,从1开始。
${status.current}   当前这次迭代的(集合中的)项
${status.first}  判断当前项是否为集合中的第一项,返回值为true或false
${status.last}   判断当前项是否为集合中的最后一项,返回值为true或false
begin、end、step分别表示:起始序号,结束序号,步长。对应java中的for
for(int i=0;i<l00;i+=2) begin位起始0  end位结束100 step位2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics