Fichier BlogDAO.java
/**Renvoie plusieurs enregistrements en fonction des conditions (par défaut, toutes les données dans une seule table)*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public List<Blog> list(String kw,Integer pageCur,Integer pageSize) {
List<Blog> list = null;
Integer limitaInteger = (pageCur-1)*pageSize;
Integer limitbInteger = pageCur*pageSize;
Object[] params = {limitaInteger,limitbInteger};
String sqlWhere = "" ;
String sql = "select * from csdn_blog where first=1 " ;
if (kw!=null && !kw.equals( "" )) {
sqlWhere = " and topic like '%" +kw+ "%'" ;
}
sql += sqlWhere;
sql += " order by id desc limit ?,?" ;
ResultSetHandler<List<Blog>> rsh = new BeanListHandler<Blog>(Blog. class );
try {
list = qr.query(getConn(), sql, rsh, params);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
|
Copier après la connexion
Fichier BlogActin.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | private Integer pagenum;
return allblogs;
}
public void setAllblogs(List<Blog> allblogs) {
this.allblogs = allblogs;
}
public Integer getPagenum() {
return pagenum;
}
public void setPagenum(Integer pagenum) {
this.pagenum = pagenum;
}
|
Copier après la connexion
------ - ------Méthode de liste
1 2 3 4 5 6 7 8 | public String alllist() { request=ServletActionContext.getRequest();
blogtopic=request.getParameter( "blogtopic" );
allblogs=blogDAO.list(blogtopic, pagenum, 10);
num_allblog=blogDAO.countAllNum(blogtopic);
num_allblogpage=num_allblog/10+1;
return "index" ;
}
|
Copier après la connexion
-----------JSPFichier
1 2 3 4 5 6 7 8 | <p class = "content" >
<c:forEach items= "${allblogs}" var = "allblog" >
<p class = "blog_list" >
<h1><a href= "#" class = "category" >[${allblog.topic}]</a>
<a name= "11519817" href= "Blog_getContent.action?id=${allblog.id}" target= "_blank" >${allblog.title}</a></h1>
<dl>
<dt><a href= "#" ><img src= "img/oyuntaolianwu.jpg" alt= "jackyvincefu" ></a></dt>
<dd><p class = "text_length" ><pre class = "brush:php;toolbar:false" >${allblog.content }
|
C++指针常量
常量指针常量指针常量
${num_allblog}条数据 共${num_allblogpage}页
[${pagenum}]
下一页
尾页
Copier après la connexion
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!