el表达式foreach循环出来的input 只能获取第一个文本框中的val,怎么解决?

转载:https://blog.csdn.net/xujiangdong1992/article/details/78069001

这是由于foreach循环生成的input都是一样的,同样的name,同样的id,获取的时候当然只能获取第一个了,那么我们就需要让他循环生成的input标签不一样,比如加个前缀或者后缀

<c:forEach items="${page.list}"  var="item"  varStatus="status">
<input id="inp${status.index}" name="inp${status.index}"/>
</c:forEach>

想必都能看懂,statux.index根据循环从0开始递增

猜你喜欢

转载自blog.csdn.net/qq_34266804/article/details/89001362