JSP开发错误集合

【c:foreach】

使用索引值,不能用i,应该用i.index

<c:forEach items="${itemIndexList}" var="indexObj" varStatus="i">
    <td id="lastSum1${i.index}" class="alignright">
        <input id="a${i.index}" class="alignright" value="1" readonly="readonly" type="text">
    </td>
    </td>
</c:forEach>

i是一个对象的形式,输出时会出现下面的代码

<td+id%3D"ajavax.servlet.jsp.jstl.core.LoopTagSupport%241Status%4074047404"+class%3D"alignright">

【空指针】

List<Map<String,Object>> resultList = null;

这样写是错误的,正确写法如下

List<Map<String,Object>> resultList = new ArrayList<Map<String, Object>>();

猜你喜欢

转载自blog.csdn.net/qq_36766417/article/details/106860782