在使用中通常会遇到在使用jstl的时候如何使用 jquery中的数据,如何在jstl <c:forEach></c:forEach>标签中 配合EL表达式使用jquery呢?
我的方式很笨,很傻,此处直接上一小段代码:
<c:forEach items="${ptype.infos}" var="info" varStatus="j">
<td width="28%" align="center">
<c:if test="${info!=null && info.id!=null}">
<a οnclick="infoView('${info.id}','${info.pics}')" href="#">
<img src="" id="path${info.id}" width="75%" border="0" />
<script type="text/javascript">
var urlpath = getImgPath(); //js中的方法
var path = urlpath+"/"+"${info.imgname}"+"${info.suffix}";
$("#path${info.id}").attr("src",path)
</script>
</a>
</c:if>
</td>
</c:forEach>
此方式个人觉得很笨拙,但是也还是能够使用实现效果的,故留下印记便日后查阅,以上也可以证明,在jstl表达式中与js是开可以共存的。