关于JSP的C标签之forEach循环分隔符

页面中可能说出现在forEach循环中间需要出力分隔符的问题,

比如:

小明 1年级,小王 2年级, 小张 3年级(循环单位是 ${bean.name} ${bean.class})

此时的逗号出力,我采用下面方法实现完成。

<c:forEach var="bean" items="students">

  <c:if test="printCommaFlag">,</c:if>

  ${bean.name}&nbsp;${bean.class}

<c:set var="printCommaFlag" value="true" scope="request"/>

</c:forEach>