无法在jsp中显示从dao获取的数据

时间:2011-03-08 11:44:03

标签: java jsp dao

  

可能重复:
  how to display data obtained from dao in jsp

我能够检索数据并在控制台上打印但我无法在jsp中打印数据是dao中的代码

while(rs.next())  
            {  
                 System.out.println(rs.getString(1) +" " + rs.getString(2)+ " "+rs.getString(3) +" " + rs.getString(4)+"<br>");  

                 SearchProjVO projVO = new SearchProjVO();
                 projVO.setProjid(rs.getString(1));
                projVO.setProjname(rs.getString(2));
                projVO.setCost(rs.getString(3));
                projVO.setManager(rs.getString(4));
                ar.add(projVO);
             }              

在jsp我以下列格式调用这些变量是正确的
      

    <td class="td-highlighted-2">
     <div align="left"><a href="UpdateProject.html">${resultList.projId}</a></div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${resultList.projName}</div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${resultList.cost}</div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${resultList.manager}</div>
    </td>
        </tr>
</c:forEach>

1 个答案:

答案 0 :(得分:1)

看起来您正在遍历结果列表。假设您在列表中有一个可从您的页面访问的SearchProjVO对象列表,那么这样的东西就可以了:

<c:forEach var="result" items="${resultList}">
    <tr>
    <td class="td-highlighted-2">
     <div align="left"><a href="UpdateProject.html">${result.projId}</a></div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${result.projname}</div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${result.cost}</div>
    </td>
    <td class="td-highlighted-2">
      <div align="left">${result.manager}</div>
    </td>
    </tr>
</c:forEach>