struts2+spring+hibernate分页

2EE系统中分页显示,修改dao层,service层,action层,两个分页类文件,代码如下:




dao层接口:
Java代码

   1. package com.last999.im.news.dao; 
   2. import java.util.*; 
   3. import com.last999.im.news.entity.KindEntity; 
   4. import com.last999.im.news.web.PageTool; 
   5. public interface KindEntityDao{ 
   6.     public KindEntity get(String uuid); 
   7.     public void save(KindEntity kindEntity); 
   8.     public void update(KindEntity kindEntity); 
   9.     public void delete(String uuid); 
  10.     public void delete(KindEntity kindEntity); 
  11.     public List<KindEntity> findAll(); 
  12.     public KindEntity findKindEntityByName(String name); 
  13.     public List<KindEntity> getKindEntity(PageTool pageInfo); 
  14.     public int getRows(); 
  15. } 

package com.last999.im.news.dao;
import java.util.*;
import com.last999.im.news.entity.KindEntity;
import com.last999.im.news.web.PageTool;
public interface KindEntityDao{
    public KindEntity get(String uuid);
    public void save(KindEntity kindEntity);
    public void update(KindEntity kindEntity);
    public void delete(String uuid);
    public void delete(KindEntity kindEntity);
    public List<KindEntity> findAll();
    public KindEntity findKindEntityByName(String name);
    public List<KindEntity> getKindEntity(PageTool pageInfo);
    public int getRows();
}







实现类:
Java代码

   1. package com.last999.im.news.dao.impl; 
   2. import java.util.*; 
   3. import com.last999.im.news.dao.KindEntityDao; 
   4. import com.last999.im.news.entity.KindEntity; 
   5. import com.last999.im.news.web.PageTool; 
   6. import org.hibernate.Query; 
   7. import org.hibernate.Session; 
   8. import org.hibernate.HibernateException; 
   9. import org.springframework.orm.hibernate3.HibernateCallback; 
  10. import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 
  11. public class KindEntityDaoHibernate extends HibernateDaoSupport implements KindEntityDao{ 
  12.     public KindEntity get(String uuid){ 
  13.         return (KindEntity)getHibernateTemplate().get(KindEntity.class,uuid); 
  14.     } 
  15.     public void save(KindEntity kindEntity){ 
  16.         getHibernateTemplate().save(kindEntity); 
  17.     } 
  18.     public void update(KindEntity kindEntity){ 
  19.         getHibernateTemplate().saveOrUpdate(kindEntity); 
  20.     } 
  21.     public void delete(KindEntity kindEntity){ 
  22.         getHibernateTemplate().delete(kindEntity); 
  23.     } 
  24.     public void delete(String uuid){ 
  25.         getHibernateTemplate().delete((KindEntity)getHibernateTemplate().get(KindEntity.class,uuid)); 
  26.     } 
  27.     public List findAll(){ 
  28.         return getHibernateTemplate().find("from KindEntity"); 
  29.     } 
  30.     public KindEntity findKindEntityByName(String name){ 
  31.         List k1 = getHibernateTemplate().find("from KindEntity as ke where ke.name = ?",name); 
  32.         if (k1 != null && k1.size() == 1){ 
  33.             return (KindEntity)k1.get(0); 
  34.         } 
  35.         return null; 
  36.     } 
  37.     public int getRows(){ 
  38.         return getHibernateTemplate().find("from KindEntity").size(); 
  39.     } 
  40.     public List getKindEntity(PageTool pageInfo){ 
  41.         final int size1=pageInfo.getSize(); 
  42.         final int startRow=(pageInfo.getCur()-1)*pageInfo.getSize(); 
  43.         return this.getHibernateTemplate().executeFind(new HibernateCallback(){ 
  44.             public List doInHibernate(Session session) throws HibernateException{ 
  45.                 Query query = session.createQuery("from KindEntity"); 
  46.                 query.setFirstResult(startRow); 
  47.                 query.setMaxResults(size1); 
  48.                 return query.list(); 
  49.             } 
  50.         } 
  51.         ); 
  52.     } 
  53. } 

package com.last999.im.news.dao.impl;
import java.util.*;
import com.last999.im.news.dao.KindEntityDao;
import com.last999.im.news.entity.KindEntity;
import com.last999.im.news.web.PageTool;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.HibernateException;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class KindEntityDaoHibernate extends HibernateDaoSupport implements KindEntityDao{
    public KindEntity get(String uuid){
        return (KindEntity)getHibernateTemplate().get(KindEntity.class,uuid);
    }
    public void save(KindEntity kindEntity){
        getHibernateTemplate().save(kindEntity);
    }
    public void update(KindEntity kindEntity){
        getHibernateTemplate().saveOrUpdate(kindEntity);
    }
    public void delete(KindEntity kindEntity){
        getHibernateTemplate().delete(kindEntity);
    }
    public void delete(String uuid){
        getHibernateTemplate().delete((KindEntity)getHibernateTemplate().get(KindEntity.class,uuid));
    }
    public List findAll(){
        return getHibernateTemplate().find("from KindEntity");
    }
    public KindEntity findKindEntityByName(String name){
        List k1 = getHibernateTemplate().find("from KindEntity as ke where ke.name = ?",name);
        if (k1 != null && k1.size() == 1){
            return (KindEntity)k1.get(0);
        }
        return null;
    }
    public int getRows(){
        return getHibernateTemplate().find("from KindEntity").size();
    }
    public List getKindEntity(PageTool pageInfo){
        final int size1=pageInfo.getSize();
        final int startRow=(pageInfo.getCur()-1)*pageInfo.getSize();
        return this.getHibernateTemplate().executeFind(new HibernateCallback(){
            public List doInHibernate(Session session) throws HibernateException{
                Query query = session.createQuery("from KindEntity");
                query.setFirstResult(startRow);
                query.setMaxResults(size1);
                return query.list();
            }
        }
        );
    }
}






SERVICE层接口:
Java代码

   1. package com.last999.im.news.service; 
   2. import java.util.List; 
   3. import com.last999.im.news.web.PageTool; 
   4. import com.last999.im.news.entity.KindEntity; 
   5. public interface KindEntityManage{ 
   6.     public void addKindEntity(KindEntity entity); 
   7.     public List findAllKind(); 
   8.     public int getRows(); 
   9.     public List getKindEntity(PageTool pageInfo); 
  10. } 

package com.last999.im.news.service;
import java.util.List;
import com.last999.im.news.web.PageTool;
import com.last999.im.news.entity.KindEntity;
public interface KindEntityManage{
    public void addKindEntity(KindEntity entity);
    public List findAllKind();
    public int getRows();
    public List getKindEntity(PageTool pageInfo);
}






实现类:
Java代码

   1. package com.last999.im.news.service.impl; 
   2. import java.util.List; 
   3. import com.last999.im.news.web.PageTool; 
   4. import com.last999.im.news.entity.KindEntity; 
   5. import com.last999.im.news.service.KindEntityManage; 
   6. import com.last999.im.news.dao.KindEntityDao; 
   7. public class KindEntityManageImpl implements KindEntityManage{ 
   8.     private KindEntityDao kindEntityDao; 
   9.     public KindEntityDao getKindEntityDao(){ 
  10.         return this.kindEntityDao; 
  11.     } 
  12.     public void setKindEntityDao(KindEntityDao kindEntityDao) { 
  13.         this.kindEntityDao=kindEntityDao; 
  14.     } 
  15.     public void addKindEntity(KindEntity kindEntity){ 
  16.         this.getKindEntityDao().save(kindEntity); 
  17.     } 
  18.     public List findAllKind(){ 
  19.         return this.getKindEntityDao().findAll(); 
  20.     } 
  21.     public int getRows(){ 
  22.         return this.getKindEntityDao().getRows(); 
  23.     } 
  24.     public List getKindEntity(PageTool pageInfo){ 
  25.         return this.getKindEntityDao().getKindEntity(pageInfo); 
  26.     } 
  27. } 

package com.last999.im.news.service.impl;
import java.util.List;
import com.last999.im.news.web.PageTool;
import com.last999.im.news.entity.KindEntity;
import com.last999.im.news.service.KindEntityManage;
import com.last999.im.news.dao.KindEntityDao;
public class KindEntityManageImpl implements KindEntityManage{
    private KindEntityDao kindEntityDao;
    public KindEntityDao getKindEntityDao(){
        return this.kindEntityDao;
    }
    public void setKindEntityDao(KindEntityDao kindEntityDao) {
        this.kindEntityDao=kindEntityDao;
    }
    public void addKindEntity(KindEntity kindEntity){
        this.getKindEntityDao().save(kindEntity);
    }
    public List findAllKind(){
        return this.getKindEntityDao().findAll();
    }
    public int getRows(){
        return this.getKindEntityDao().getRows();
    }
    public List getKindEntity(PageTool pageInfo){
        return this.getKindEntityDao().getKindEntity(pageInfo);
    }
}






action类:
Java代码

   1. package com.last999.im.news.action; 
   2. import java.util.List; 
   3. import com.last999.im.news.web.PageTool; 
   4. import com.last999.im.news.web.PageMaker; 
   5. import com.last999.im.news.entity.KindEntity; 
   6. import com.last999.im.news.service.KindEntityManage; 
   7. public class KindViewAction extends SafeStruts2{ 
   8.     private List kindList; 
   9.     private KindEntity kindEntity; 
  10.     private KindEntityManage kindEntityManage; 
  11.     private int ppp; 
  12.     private PageMaker pageMaker; 
  13.     private String pager; 
  14.     public String getPager(){ 
  15.         return this.pager; 
  16.     } 
  17.     public void setPager(String pager) { 
  18.         this.pager=pager; 
  19.     } 
  20.     public PageMaker getPageMaker(){ 
  21.         return this.pageMaker; 
  22.     } 
  23.     public void setPageMaker(PageMaker pageMaker) { 
  24.         this.pageMaker=pageMaker; 
  25.     } 
  26.     public int getPpp(){ 
  27.         return this.ppp; 
  28.     } 
  29.     public void setPpp(int ppp) { 
  30.         this.ppp=ppp; 
  31.     } 
  32.     public KindEntityManage getKindEntityManage(){ 
  33.         return this.kindEntityManage; 
  34.     } 
  35.     public void setKindEntityManage(KindEntityManage kindEntityManage) { 
  36.         this.kindEntityManage=kindEntityManage; 
  37.     } 
  38.     public KindEntity getKindEntity(){ 
  39.         return this.kindEntity; 
  40.     } 
  41.     public void setKindEntity(KindEntity kindEntity) { 
  42.         this.kindEntity=kindEntity; 
  43.     } 
  44.     public List getKindList(){ 
  45.         return this.kindList; 
  46.     } 
  47.     public void setKindList(List kindList) { 
  48.         this.kindList=kindList; 
  49.     } 
  50.     public String kindView(){ 
  51.         PageTool pageInfo = new PageTool(); 
  52.         pageInfo.setCur(this.getPpp()); 
  53.         pageInfo.setTotal(this.getKindEntityManage().getRows()); 
  54.         setKindList(this.getKindEntityManage().getKindEntity(pageInfo)); 
  55.         PageMaker pageMaker = new PageMaker(); 
  56.         setPager(pageMaker.makeList(pageInfo,"kindView.action?ppp=")); 
  57.         return SUCCESS; 
  58.     } 
  59. } 

package com.last999.im.news.action;
import java.util.List;
import com.last999.im.news.web.PageTool;
import com.last999.im.news.web.PageMaker;
import com.last999.im.news.entity.KindEntity;
import com.last999.im.news.service.KindEntityManage;
public class KindViewAction extends SafeStruts2{
    private List kindList;
    private KindEntity kindEntity;
    private KindEntityManage kindEntityManage;
    private int ppp;
    private PageMaker pageMaker;
    private String pager;
    public String getPager(){
        return this.pager;
    }
    public void setPager(String pager) {
        this.pager=pager;
    }
    public PageMaker getPageMaker(){
        return this.pageMaker;
    }
    public void setPageMaker(PageMaker pageMaker) {
        this.pageMaker=pageMaker;
    }
    public int getPpp(){
        return this.ppp;
    }
    public void setPpp(int ppp) {
        this.ppp=ppp;
    }
    public KindEntityManage getKindEntityManage(){
        return this.kindEntityManage;
    }
    public void setKindEntityManage(KindEntityManage kindEntityManage) {
        this.kindEntityManage=kindEntityManage;
    }
    public KindEntity getKindEntity(){
        return this.kindEntity;
    }
    public void setKindEntity(KindEntity kindEntity) {
        this.kindEntity=kindEntity;
    }
    public List getKindList(){
        return this.kindList;
    }
    public void setKindList(List kindList) {
        this.kindList=kindList;
    }
    public String kindView(){
        PageTool pageInfo = new PageTool();
        pageInfo.setCur(this.getPpp());
        pageInfo.setTotal(this.getKindEntityManage().getRows());
        setKindList(this.getKindEntityManage().getKindEntity(pageInfo));
        PageMaker pageMaker = new PageMaker();
        setPager(pageMaker.makeList(pageInfo,"kindView.action?ppp="));
        return SUCCESS;
    }
}






分页辅助工具类:
Java代码

   1. package com.last999.im.news.web; 
   2.  
   3. public class PageTool{ 
   4.      
   5.     private int cur=1; 
   6.     private int size=6; 
   7.     private int total=1; 
   8.  
   9.     public int getCur(){ 
  10.         return this.cur; 
  11.     } 
  12.     public void setCur(int cur) { 
  13.         this.cur=cur; 
  14.     } 
  15.     public int getSize(){ 
  16.         return this.size; 
  17.     } 
  18.     public void setSize(int size) { 
  19.         this.size=size; 
  20.     } 
  21.     public int getTotal(){ 
  22.         return this.total; 
  23.     } 
  24.     public void setTotal(int total) { 
  25.         this.total=total; 
  26.     } 
  27.  
  28.     public PageTool(){} 
  29.  
  30.     public PageTool(int cur,int size,int total){ 
  31.         this.cur=cur; 
  32.         this.size=size; 
  33.         this.total=total; 
  34.     } 
  35.  
  36.     public PageTool(int size){ 
  37.         this.size=size; 
  38.         this.cur=1; 
  39.         this.total=1; 
  40.     } 
  41. } 

package com.last999.im.news.web;

public class PageTool{
   
    private int cur=1;
    private int size=6;
    private int total=1;

    public int getCur(){
        return this.cur;
    }
    public void setCur(int cur) {
        this.cur=cur;
    }
    public int getSize(){
        return this.size;
    }
    public void setSize(int size) {
        this.size=size;
    }
    public int getTotal(){
        return this.total;
    }
    public void setTotal(int total) {
        this.total=total;
    }

    public PageTool(){}

    public PageTool(int cur,int size,int total){
        this.cur=cur;
        this.size=size;
        this.total=total;
    }

    public PageTool(int size){
        this.size=size;
        this.cur=1;
        this.total=1;
    }
}






PageMaker.java

Java代码

   1. package com.last999.im.news.web; 
   2.  
   3.  
   4. import com.last999.im.news.web.PageTool; 
   5.  
   6. public class PageMaker { 
   7.     public PageMaker(){} 
   8.     public String makeList(PageTool pageinfo,String url){ 
   9.        int  linkNumber=10; 
  10.        int  halfLinkNumber=5; 
  11.        String pageStyle="<style> .ptbl {border:1px solid #CEDBEF;font-size:12px;padding:0;font-family:Arial;width:auto} .ptbl a {text-decoration:none;color:#555555} .ptbl td {padding-top:0px;padding-bottom:0px;padding-left:4px;padding-right:4px}    .strong {background:#CEDBEF;font-weight:800;color:#FF7D00}    .strong a{color:#FF7D00} .page_input {background:#ffffff;border:1px solid #CEDBEF;border-top:none;border-bottom:none;color:#FF7D00;width:30px;margin:0px } </style>"; 
  12.        String pageTable="<table border='0'cellpadding='0' cellspacing='0' bgcolor='#CEDBEF' class='ptbl'><tr align='center' bgcolor='#FFFBFF'>"; 
  13.        //a string that will be decretion to show 
  14.         StringBuffer pagelist=new StringBuffer(""); 
  15.         //get current page. 
  16.         int curpage=pageinfo.getCur(); 
  17.         int pagenumber=pageinfo.getTotal()/pageinfo.getSize()+1; 
  18.         //make it's pre,next page 
  19.         int prepage=curpage-1; 
  20.         prepage=prepage<=0?1:prepage; 
  21.         int nextpage=curpage+1; 
  22.         nextpage=nextpage>=pagenumber?pagenumber:nextpage; 
  23.         //finger out how many page total 
  24.         pagelist.append(pageStyle); 
  25.         pagelist.append(pageTable); 
  26.         pagelist.append("<td>Record:<font color='red'>"+pageinfo.getTotal()+"</font></td>"); 
  27.         //frist page 
  28.         //pagelist.append("<td><a href='"+url+"1'>|&lt;</a></td>"); 
  29.         //pagelist.append("<td><a href='"+url+prepage+"'>&lt;</a></td>"); 
  30.        if (pagenumber<=linkNumber){ 
  31.           for(int i=1;i<=pagenumber;i++){ 
  32.             if(i==curpage) 
  33.                pagelist.append("<td class='strong'>"+i+"</td>"); 
  34.             else 
  35.                pagelist.append("<td><a href='"+url+i+"'>"+i+"</a></td>"); 
  36.           } 
  37.        }else{ 
  38.           int begin=curpage-halfLinkNumber; 
  39.           begin=(begin<=0)?1:begin; 
  40.           begin=((halfLinkNumber+curpage)>pagenumber) ? (pagenumber-linkNumber+1):begin; 
  41.           for(int i=begin;i<=linkNumber+begin-1;i++){ 
  42.             if(i==curpage){ 
  43.                pagelist.append("<td class='strong'>"+i+"</td>"); 
  44.                pagelist.append("\n"); 
  45.             } 
  46.             else{ 
  47.                pagelist.append("<td><a href='<s:url action='"+url+"'><s:param name='ppp' value='"+i+"'/></s:url>'>"+i+"</a></td>"); 
  48.                pagelist.append("\n"); 
  49.             } 
  50.           } 
  51.        } 
  52.         //pagelist.append("<td><a href='"+url+nextpage+"'>&gt;</a></td>"); 
  53.         //pagelist.append("<td><a href='"+url+pagenumber+"'>&gt;|</a></td>"); 
  54.         pagelist.append("<td>Page:<font color='red'>"+pagenumber+"</font></td></tr></table>"); 
  55.         return pagelist.toString(); 
  56.     } 
  57. } 

package com.last999.im.news.web;


import com.last999.im.news.web.PageTool;

public class PageMaker {
    public PageMaker(){}
    public String makeList(PageTool pageinfo,String url){
       int  linkNumber=10;
       int  halfLinkNumber=5;
       String pageStyle="<style> .ptbl {border:1px solid #CEDBEF;font-size:12px;padding:0;font-family:Arial;width:auto} .ptbl a {text-decoration:none;color:#555555} .ptbl td {padding-top:0px;padding-bottom:0px;padding-left:4px;padding-right:4px}    .strong {background:#CEDBEF;font-weight:800;color:#FF7D00}    .strong a{color:#FF7D00} .page_input {background:#ffffff;border:1px solid #CEDBEF;border-top:none;border-bottom:none;color:#FF7D00;width:30px;margin:0px } </style>";
       String pageTable="<table border='0'cellpadding='0' cellspacing='0' bgcolor='#CEDBEF' class='ptbl'><tr align='center' bgcolor='#FFFBFF'>";
       //a string that will be decretion to show
        StringBuffer pagelist=new StringBuffer("");
        //get current page.
        int curpage=pageinfo.getCur();
        int pagenumber=pageinfo.getTotal()/pageinfo.getSize()+1;
        //make it's pre,next page
        int prepage=curpage-1;
        prepage=prepage<=0?1:prepage;
        int nextpage=curpage+1;
        nextpage=nextpage>=pagenumber?pagenumber:nextpage;
        //finger out how many page total
        pagelist.append(pageStyle);
        pagelist.append(pageTable);
        pagelist.append("<td>Record:<font color='red'>"+pageinfo.getTotal()+"</font></td>");
        //frist page
        //pagelist.append("<td><a href='"+url+"1'>|&lt;</a></td>");
        //pagelist.append("<td><a href='"+url+prepage+"'>&lt;</a></td>");
       if (pagenumber<=linkNumber){
          for(int i=1;i<=pagenumber;i++){
            if(i==curpage)
               pagelist.append("<td class='strong'>"+i+"</td>");
            else
               pagelist.append("<td><a href='"+url+i+"'>"+i+"</a></td>");
          }
       }else{
          int begin=curpage-halfLinkNumber;
          begin=(begin<=0)?1:begin;
          begin=((halfLinkNumber+curpage)>pagenumber) ? (pagenumber-linkNumber+1):begin;
          for(int i=begin;i<=linkNumber+begin-1;i++){
            if(i==curpage){
               pagelist.append("<td class='strong'>"+i+"</td>");
               pagelist.append("\n");
            }
            else{
               pagelist.append("<td><a href='<s:url action='"+url+"'><s:param name='ppp' value='"+i+"'/></s:url>'>"+i+"</a></td>");
               pagelist.append("\n");
            }
          }
       }
        //pagelist.append("<td><a href='"+url+nextpage+"'>&gt;</a></td>");
        //pagelist.append("<td><a href='"+url+pagenumber+"'>&gt;|</a></td>");
        pagelist.append("<td>Page:<font color='red'>"+pagenumber+"</font></td></tr></table>");
        return pagelist.toString();
    }
}








KindEntity.java


Java代码

   1. package com.last999.im.news.entity; 
   2. /**
   3.  * @hibernate.class
   4.  * table="kind"
   5.  * dynamic-update="true"
   6.  */ 
   7. public class KindEntity extends Persistent{ 
   8.     private String title; 
   9.     private String content; 
  10.     private String parentId; 
  11.     private String description; 
  12.     /**
  13.      * @hibernate.property
  14.      */ 
  15.     public String getDescription(){ 
  16.         return this.description; 
  17.     } 
  18.     public void setDescription(String description) { 
  19.         this.description=description; 
  20.     } 
  21.     private String em1; 
  22.     private String em2; 
  23.     private String em3; 
  24.     /**
  25.      * @hibernate.property
  26.      */ 
  27.     public String getEm3(){ 
  28.         return this.em3; 
  29.     } 
  30.     public void setEm3(String em3) { 
  31.         this.em3=em3; 
  32.     } 
  33.     /**
  34.      * @hibernate.property
  35.      */ 
  36.     public String getEm2(){ 
  37.         return this.em2; 
  38.     } 
  39.     public void setEm2(String em2) { 
  40.         this.em2=em2; 
  41.     } 
  42.     /**
  43.      * @hibernate.property
  44.      */ 
  45.     public String getEm1(){ 
  46.         return this.em1; 
  47.     } 
  48.     public void setEm1(String em1) { 
  49.         this.em1=em1; 
  50.     } 
  51.     /**
  52.      * @hibernate.property
  53.      */ 
  54.     public String getParentId(){ 
  55.         return this.parentId; 
  56.     } 
  57.     public void setParentId(String parentId) { 
  58.         this.parentId=parentId; 
  59.     } 
  60.     /**
  61.      * @hibernate.property
  62.      * @hibernate.column name="content" sql-type="TEXT"
  63.      */ 
  64.     public String getContent(){ 
  65.         return this.content; 
  66.     } 
  67.     public void setContent(String content) { 
  68.         this.content=content; 
  69.     } 
  70.     /**
  71.      * @hibernate.property 
  72.      */ 
  73.     public String getTitle(){ 
  74.         return this.title; 
  75.     } 
  76.     public void setTitle(String title) { 
  77.         this.title=title; 
  78.     } 
  79. } 

package com.last999.im.news.entity;
/**
* @hibernate.class
* table="kind"
* dynamic-update="true"
*/
public class KindEntity extends Persistent{
    private String title;
    private String content;
    private String parentId;
    private String description;
    /**
     * @hibernate.property
     */
    public String getDescription(){
        return this.description;
    }
    public void setDescription(String description) {
        this.description=description;
    }
    private String em1;
    private String em2;
    private String em3;
    /**
     * @hibernate.property
     */
    public String getEm3(){
        return this.em3;
    }
    public void setEm3(String em3) {
        this.em3=em3;
    }
    /**
     * @hibernate.property
     */
    public String getEm2(){
        return this.em2;
    }
    public void setEm2(String em2) {
        this.em2=em2;
    }
    /**
     * @hibernate.property
     */
    public String getEm1(){
        return this.em1;
    }
    public void setEm1(String em1) {
        this.em1=em1;
    }
    /**
     * @hibernate.property
     */
    public String getParentId(){
        return this.parentId;
    }
    public void setParentId(String parentId) {
        this.parentId=parentId;
    }
    /**
     * @hibernate.property
     * @hibernate.column name="content" sql-type="TEXT"
     */
    public String getContent(){
        return this.content;
    }
    public void setContent(String content) {
        this.content=content;
    }
    /**
     * @hibernate.property
     */
    public String getTitle(){
        return this.title;
    }
    public void setTitle(String title) {
        this.title=title;
    }
}








为什么没有在页面接收的代码:



Html代码

   1. <%@ page contentType="text/html;charset=utf-8" language="java" %> 
   2. <%@ taglib prefix="s" uri="/struts-tags"%> 
   3. <html> 
   4.   <head> 
   5.     <title> 
   6.       showkind 
   7.     </title> 
   8.   </head> 
   9.   <html> 
  10.     <body> 
  11.     <center> 
  12.       <table border="1"> 
  13.         <tr> 
  14.           <td> 
  15.         <table border="0" width="755" bgcolor="#eeeeee"> 
  16.           <tr> 
  17.             <font size="3"> 
  18.               <b> 
  19.               These are all the kinds: 
  20.               </b> 
  21.             </font> 
  22.           </tr> 
  23.           <tr> 
  24.             <td width="%25">title</td> 
  25.             <td width="%25">description</td> 
  26.             <td width="%25">parentId</td> 
  27.             <td width="25%">Content</td>  
  28.           </tr> 
  29.           <s:iterator value="%{kindList}" id="kind"> 
  30.           <tr> 
  31.             <td> 
  32.               <s:property value="#kind.title"/> 
  33.             </td> 
  34.             <td> 
  35.               <s:property value="#kind.description"/> 
  36.             </td> 
  37.             <td> 
  38.               <s:property value="#kind.parentId"/> 
  39.             </td> 
  40.             <td> 
  41.               <s:property value="#kind.content"/> 
  42.             </td> 
  43.    <!-- 
  44.             <td> 
  45.               <a href="<s:url action='kindDelete'><s:param name='uuid' value='#kind.uuid'/></s:url>">Delete</a> 
  46.             </td> 
  47.    --> 
  48.      </s:iterator> 
  49.         </tr> 
  50.    </table> 
  51.  </td> 
  52.  </tr> 
  53.  </table> 
  54.  <s:property value="pager" escape="false"/> 
  55.  </center> 
  56.  </body> 
  57.  </html> 

你可能感兴趣的:(DAO,spring,Hibernate,Web,orm)