严重: Servlet.service() for servlet EmpSer threw exception
javax.servlet.jsp.el.ELException: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
这个错误报的一点也不好,检查了半天的类型,没错,又跟程序debug走一遍,没错
然后把
<html:select property="kkDW" > <html:option value="">--请选择单位--</html:option> <c:forEach var="listCode" items="${listCode}"> <html:option value="${listCode.kkDW}">${listCode.kkDW}</html:option> </c:forEach> </html:select>
改成
<html:select property="kkDW" > <html:option value="">--请选择单位--</html:option> <c:forEach var="listCodes" items="${listCode}"> <html:option value="${listCodes.kkDW}">${listCodes.kkDW}</html:option> </c:forEach> </html:select>
之后不报错了,但是就是取不到listCodes.kkDW的值
后来
<% for(int i = 0; i < listCode.size(); i++) { KK_BlacklistVehicle_UserEnrolForm bean = (KK_BlacklistVehicle_UserEnrolForm)listCode.get(i); System.out.println("页面上输出的:======="+bean.getKk_BlacklistVehicle_UserEnrol_DW()); } %>
遍历了一下这个list,发现可以输出值来
那是什么原因呢,不报错了,还取不到值
用
<c:if test="${empty listCode}"> <%out.print("not get list value"); %> </c:if>
测试发现是输出not get list value的,那就是说listCode为空
最后,找了好久,终于解决了
解决办法:在JSP头文件上加入
<%@ taglib uri="/tags/c" prefix="c" %>
问题解决!