2011-03-08 50 views
0

可能重複:
how to display data obtained from dao in jsp無法在JSP中顯示從DAO獲得的數據

您好我能夠檢索數據並打印在控制檯上,但我無法打印在jsp下面的數據是道的代碼

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我在調用這些變量在fol降脂格式這是正確的

<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> 
+2

你怎麼把值從dao傳遞給jsp? – Bozho 2011-03-08 11:47:45

回答

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>