List  roles = roleservice.searchRoles(); 返回的是一个list ServletActionContext.getRequest().setAttribute("pm", roles);javax.servlet.ServletException: 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.如果返回的是一个list,我在页面怎样写 list的role对象,id name等属性,应该怎样做输出
jsp页面:这样写抛出上面的错误<c:if test="${!empty pm.list}">
          <c:forEach items="${pm.list }" var="role">
      <tr bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';">
      <td align="center" vAlign="middle">${role.id }</td>
          <td align="center" vAlign="middle">${role.name }</td>
          <td align="center" vAlign="middle">

解决方案 »

  1.   

    <c:if test="${!empty pm}"> 
              <c:forEach items="${pm}" var="role"> 
          <tr bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';"> 
          <td align="center" vAlign="middle">${role.id } </td> 
              <td align="center" vAlign="middle">${role.name } </td> 
              <td align="center" vAlign="middle"> 
     
     
     
      

  2.   

    items="${pm.list }"?
      

  3.   

    ServletActionContext.getRequest().setAttribute("pm", roles); 
    这里pm就已经将roles这个list对象保存起来了通过jstl取它时,只要用这个变量名pm就可以了,所以在:
    <c:if test="${!empty pm.list}"> 
              <c:forEach items="${pm.list }" var="role">这里的 
    "${!empty pm.list}"只要写成${!empty pm},还有"${pm.list }" 改成${pm}就可以了
      

  4.   

    按照上面,我改成pm 去list 还是照样9:03:33,187 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/oa3].[jsp]:711 - Servlet.service() for servlet jsp 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.页面 type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request. 还是不能获取
      

  5.   


    在百度上找到了一个博客一样的错误,不太理解,
    如下:
    如果你确定引用了<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>,那么你返回的是否是一个List的集合呢?如果是,别忘了加上一个索引。例如:${userInfo[0].USERNAME}求高人,到底哪里出错了,