资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

struts 分页显示问题

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

大家好,有个struts分页简单方法,在网上查的,怎么行不通,帮忙看看   ,有人用过这种方法吗,这方法行的通吗?我照着做的时候   提示:No   getter   method   for   property   groupName   of   bean   group     错误。  
  commons-beanutils     这个包我是更新换了的,为什么会提示   需要bean,getter方法了?  
   
   
  在网上查到的一个较好的解决方案:  
  As   it   happens,   though,   I   just   checked   in   a   change   in   commons-beanutils  
  that   can   be   used   for   this   purpose,   if   youre   using   Struts   1.1.  
  Basically,   theres   now   a   really   simple   way   to   copy   the   contents   of   a  
  ResultSet   into   a   list   of   DynaBeans.   This   really   is   a   *copy*   operation,  
  so   you   have   to   pay   some   performance   and   memory   cost,   but   it   lets   you  
  pass   the   data   without   having   to   create   custom   beans,   and   without   leaving  
  the   ResultSet   open.  
   
  Youll   need   to   grab   a   very   recent   nightly   build   of   commons-beanutils  
  from:  
   
   
  http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-beanuti  
  ls  
   
  and   replace   your   commons-beanutils.jar   file   if   you   want   to   try   this.  
   
  >   Please   include   the   .java   and   .jsp   code.  
  >  
   
  In   your   Java   code,   youd   do   something   like   this:  
   
  Connection   conn   =   ...;   //   Get   connection   from   the   pool  
  Statement   stmt   =   conn.createStatement();  
  ResultSet   rs   =   stmt.executeQuery("select   custid,   name   from  
  customers");  
  RowSetDynaClass   rsdc   =   new   RowSetDynaClass(rs);  
  rs.close();  
  stmt.close();  
  ...   return   connection   to   the   pool   ...  
  request.setAttribute("custoemrs",   rsdc.getRows());  
   
  In   your   JSP   page,   treat   this   List   of   DynaBeans   like   you   would   any   other  
  collection   of   beans,   because   all   the   Struts   tags   know   how   to   deal   with  
  DynaBeans.  
   
  <table>  
  <tr>  
  <th>Customer   ID</th>  
  <th>Customer   Name</th>  
  </tr>  
  <logic:iterate   name="customers"   id="customer">  
  <tr>  
  <td><bean:write   name="customer"   property="custid"/></td>  
  <td><bean:write   name="customer"   property="name"/></td>  
  </tr>  
  </logic:iterate>  
  </table>  
   
  See   the   updated   Javadocs   for   commons-beanutils   (included   in   the   binary  
  distribution)   for   class   org.apache.commons.beanutils.RowSetDataSource  
  for   more   information   about   this   class.    
   
 

网友回答:


 

 
热门推荐笔记本: IBM笔记本
相关文章:
笔记本相关:
IT技术文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved