当前位置: 移动技术网 > IT编程>开发语言>Java > struts2+spring+hibernate分页代码[比较多]第1/7页

struts2+spring+hibernate分页代码[比较多]第1/7页

2017年12月12日  | 移动技术网IT编程  | 我要评论
dao层接口: java代码 复制代码 代码如下: package com.last999.im.news.dao; import java.util.*; import

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'>|<</a></td>");
//pagelist.append("<td><a href='"+url+prepage+"'><</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+"'>></a></td>");
//pagelist.append("<td><a href='"+url+pagenumber+"'>>|</a></td>");
pagelist.append("<td>page:<font color='red'>"+pagenumber+"</font></td></tr></table>");
return pagelist.tostring();
}
}






kindentity.java


java代码
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;
}
}
view plaincopy to clipboardprint?
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;
}
}

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代码
<%@ page contenttype="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>
showkind
</title>
</head>
<html>
<body>
<center>
<table border="1">
<tr>
<td>
<table border="0" width="755" bgcolor="#eeeeee">
<tr>
<font size="3">
<b>
these are all the kinds:
</b>
</font>
</tr>
<tr>
<td width="%25">title</td>
<td width="%25">description</td>
<td width="%25">parentid</td>
<td width="25%">content</td>
</tr>
<s:iterator value="%{kindlist}" id="kind">
<tr>
<td>
<s:property value="#kind.title"/>
</td>
<td>
<s:property value="#kind.description"/>
</td>
<td>
<s:property value="#kind.parentid"/>
</td>
<td>
<s:property value="#kind.content"/>
</td>
<!--
<td>
<a href="<s:url action='kinddelete'><s:param name='uuid' value='#kind.uuid'/></s:url>">delete</a>
</td>
-->
</s:iterator>
</tr>
</table>
</td>
</tr>
</table>
<s:property value="pager" escape="false"/>
</center>
</body>
</html>
7

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网