struts1 分页

分页代码:

首先是分页对象:
package sboss.framework.dao.util;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-8-9
 * Time: 9:49:12
 * To change this template use File | Settings | File Templates.
 */
public class Page {

    public final int DEFAULT_PAGESIZE = 10;//默认10条一页
    public final int DEFAULT_PAGE = 1;      //默认从第一页开始
    public final int DEFAULT_STARTINDEX = 0;//默认从第0条记录开始

    private int totalNum ;          //总记录数
    private int pageSize;           //每页记录数
    private int pageCount;          //总页数
    private int pageNum;          //当前页码
    private int startIndex;         //起始记录下标

    private boolean init;       //默认是false,当为true时,表示page初始完成,否则不可用

    private PType pt;
    public static enum PType {
        STARTINDEX,//指示表示参数为 记录下标
        PAGENUM,    //指示表示参数为 页码
    }

    public Page(){
        this.pageSize = DEFAULT_PAGESIZE;
        this.pageNum = DEFAULT_PAGE;
        this.startIndex = DEFAULT_STARTINDEX;
        //默认是页码的形式
        this.pt=PType.PAGENUM;
    }

    public Page(int pageSize,int param,PType pt){
        this.pageSize = pageSize<1 ? 1 : pageSize;
        this.pt = pt;
        if(PType.PAGENUM.equals(this.pt)){
            this.pageNum = param<1 ? 1 : param;
        }else if(PType.STARTINDEX.equals(this.pt)){
            this.startIndex = param<0 ? 0 : param;
        }
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum<0 ? 0 : totalNum;
        this.pageCount = (this.totalNum+pageSize-1)/pageSize;

        if(PType.PAGENUM.equals(this.pt)){
            if(pageNum>pageCount)
                pageNum = pageCount;
            if(pageNum<1)
                pageNum = 1;
            this.startIndex = (pageNum-1)*pageSize;
        }else if(PType.STARTINDEX.equals(this.pt)){
            if(startIndex>=this.totalNum){
                this.startIndex = (this.totalNum-1<0)? 0 : this.totalNum-1;
            }
            this.pageNum = (this.startIndex+this.pageSize)/this.pageSize;
        }else{
            this.pageNum = DEFAULT_PAGE;
            this.startIndex = DEFAULT_STARTINDEX;
        }

        this.init = true;
    }

    public boolean isInit() {
        return init;
    }

    public int getTotalNum() {
        return totalNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getPageCount() {
        return pageCount;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }
}




package sboss.framework.model;

/**
 * User: Administrator
 * Date: 2006-2-13
 * Time: 15:09:40
 */
public class PageInfo
{
    // this is sign, which means the-last-page
    // and is useful when a new object is added and 
    // the last-page is not know.
    // if the currentPage is set THE_LAST_PAGE,
    // those *list* function should re-calculate the currentPage
    // and set it be the REAL last page.
    public static int THE_LAST_PAGE = 100000;

    public PageInfo() {
    }

    public PageInfo(int pageSize, int currentPage) {
        this.pageSize = pageSize;
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public String getDestURL() {
        return destURL;
    }

    public void setDestURL(String destURL) {
        this.destURL = destURL;
    }

    /**
     *
     * @return a mysql page-split sql-string
     */
    public String toMySqlString()
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" limit ").append(this.getStartIndex());
        sb.append(",").append(this.pageSize);
        return sb.toString();
    }

    /**
     * @return the query start position
     */
    public int getStartIndex()
    {
        return (this.currentPage - 1) * this.pageSize;// + 1;
    }

    /**
     *
     */
    public int getTotalPages()
    {
        int i = this.total / this.pageSize;
        int m = this.total % this.pageSize;
        //return i < 1 && this.total > 0 ? 1 : i;
        return i + (m != 0 ? 1 : 0);
    }

    private int pageSize;
    private int currentPage;
    private int total;
    private String destURL;
}




服务层调用分页:
package sboss.serviceCall.service.impl;

import sboss.serviceCall.service.ServiceCallService;
import sboss.serviceCall.entity.ServiceCall;
import sboss.serviceCall.dao.ServiceCallDAO;
import sboss.serviceCall.vo.ServiceCallVo;
import sboss.framework.dao.util.Page;
import sboss.framework.dao.util.IQueryCallback;

import java.util.List;
import java.util.Date;
import java.util.ArrayList;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.Order;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-12-10
 * Time: 16:48:39
 * To change this template use File | Settings | File Templates.
 */
@Transactional(propagation= Propagation.REQUIRED)
public class ServiceCallServiceImpl  implements ServiceCallService {

    private static Log log = LogFactory.getLog(ServiceCallServiceImpl.class);

    private ServiceCallDAO serviceCalldao;

    public ServiceCallDAO getServiceCalldao() {
        return serviceCalldao;
    }

    
    public ServiceCallVo selectServiceCall(final ServiceCallVo serviceCallVo, Page page) {
      List<ServiceCall> list = null;
        list = this.serviceCalldao.listByCriteria(new IQueryCallback(){
            public Criteria initCriteria(Criteria criteriac){
            //    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
                String scType = "0";
              criteriac.add(Restrictions.eq(("status"),scType));
              criteriac.add(Restrictions.eq(("deleteFlag"),0));
             // 操作人  criteriac.add(Restrictions.or(Restrictions.eq("owner",serviceProductVO.getOwnerID()),Restrictions.eq("creator",serviceProductVO.getOwnerID())));
                return criteriac;
            }
            public Criteria addOrders(Criteria criteria){
                if("desc".equals(serviceCallVo.getOrderdesc())){
                    criteria.addOrder(Order.desc(serviceCallVo.getOrderBy()));
                }
                else{
                    criteria.addOrder(Order.asc(serviceCallVo.getOrderBy()));
                }
                return  criteria;
            }
        },page);
        ServiceCallVo scVo = new ServiceCallVo();
        scVo.setList(list);
        scVo.setPage(page);

        return scVo; 
    }

   
}


struts1 web action
  package sboss.serviceCall.web.action;

import sboss.framework.web.action.AbstractDispatchActionSupport;
import sboss.serviceCall.service.ServiceCallService;
import sboss.serviceCall.web.form.ServiceCallForm;
import sboss.serviceCall.vo.ServiceCallVo;
import sboss.serviceCall.entity.ServiceCall;
import sboss.framework.client.UtilClient;
import sboss.framework.dao.util.Page;
import sboss.framework.model.PageInfo;
import sboss.hr.model.Staff;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.text.SimpleDateFormat;

/**
 * Created by IntelliJ IDEA.
 * User: Rao Lin
 * Date: 2010-12-10
 * Time: 17:19:21
 * To change this template use File | Settings | File Templates.
 */
public class ServiceCallAction extends AbstractDispatchActionSupport {
      /**
     * 服务首页(查询出所有可用的服务产品)
     */
    public ActionForward showIndex(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception  {
        ServiceCallService serviceCallService = (ServiceCallService)this.getWebApplicationContext().getBean("serviceCallService");
        String search=request.getParameter("search")==null?"":request.getParameter("search");

        int countRecord= 0;               //记录总条数
        ServiceCallForm  scForm = (ServiceCallForm)form;
        ServiceCallVo serviceCallVo = new ServiceCallVo();
        String startTime = scForm.getCreate_time() ==null?"":scForm.getCreate_time();
        List serviceCallList = null;
           if(search.equals("false")){

           }
           else{
        
           }
        UtilClient util = new UtilClient();
        Staff staff=util.getCurrentStaff(request);
        String ownerID =  staff.getId();
     //  serviceCallVo.setCallUser_ID(ownerID);
        String orderbyname =request.getParameter("orderbyname")==null?"":request.getParameter("orderbyname");
        String orderdesc=request.getParameter("orderdesc")==null?"":request.getParameter("orderdesc");
        String serviceCallType = request.getParameter("status")==null?"":request.getParameter("status");
                                                          //设置查询表单类型
        if(orderbyname.equals("")  && orderdesc.equals("")){
            //根据创建时间降序排序
            orderbyname="create_time";
            orderdesc="desc";
            serviceCallVo.setOrderBy(orderbyname);
            serviceCallVo.setOrderdesc(orderdesc);

        }else{
            if(orderbyname.equals("create_time")){
             serviceCallVo.setOrderBy(orderbyname);
               serviceCallVo.setOrderdesc(orderdesc);
            }else{
               serviceCallVo.setOrderBy(orderbyname);
              serviceCallVo.setOrderdesc(orderdesc);
            }

        }
        request.setAttribute("orderbyname",orderbyname);
        request.setAttribute("orderdesc",orderdesc);



        PageInfo pageInfo = (PageInfo) request.getAttribute("pageInfo");
        String pageSize = request.getParameter("pageSize");
        String currentPage = request.getParameter("currentPage");
        Page page = new Page(pageSize!=null ? Integer.parseInt(pageSize) : 10,
                currentPage!=null ? Integer.parseInt(currentPage) : 1,Page.PType.PAGENUM);

        ServiceCallVo  selectServiceCall;          //创建个vo对象用于接收service查询之后的返回对象
        Page selectPage ;
        selectServiceCall =  serviceCallService.selectServiceCall(serviceCallVo,page);
        selectPage = selectServiceCall.getPage();
        pageInfo.setPageSize(selectPage.getPageSize());          //设置页面显示条数
        pageInfo.setCurrentPage(selectPage.getPageNum());        //设置当前页码
        pageInfo.setTotal(selectPage.getTotalNum());             //设置总记录数
        request.setAttribute("pageInfo",pageInfo);             //设置分页
        request.setAttribute("serviceCallList",selectServiceCall.getList());
        request.setAttribute("status",serviceCallType);
        countRecord =  pageInfo.getTotal();
        request.setAttribute("countRecord",countRecord);

        return mapping.findForward("showServiceCallIndex");
}


    
    




       }





}




vo
package sboss.serviceCall.vo;

import sboss.serviceCall.entity.ServiceCall;
import sboss.framework.dao.util.Page;

import java.util.List;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-12-13
 * Time: 10:09:18
 * To change this template use File | Settings | File Templates.
 */
public class ServiceCallVo {
   private int id;//表单ID
   private String     serviceCallNo     ; //   服务请求单编号
    private String  customer_ID         ; //  服务请求单客户id
    private String  customer_Name       ; // 服务请求单客户名称
   private String  contact_ID          ; //  服务请求单客户服务合同
    private Integer  channel_ID          ; //  服务商ID
    private String  telephone           ; //  服务请求人电话
    private String   address             ; //  服务请求人人地址
    private String  email              ; //   服务请求人人电子邮件
    private String  callUser_ID         ; //  服务请求人人ID
    private String  callUser_Name       ; //  服务请求人人名称
    private String  description         ; //  服务请求人内容
     private Date call_time           ; // 服务请求人时间
    private  Date  replay_time        ; // 回访时间
     private String replay_result       ; // 回访结果
     private Date close_time          ; // 服务请求人关闭时间
    private Date  create_time         ; // 服务请求人创建时间
    private String  creator            ; //  服务请求人创建人
    private String  status        ; //  服务请求人告单状态
    private String      subject ;     // 主题
    private String orderdesc ; //升序,或者降序
    private String orderBy ;  //根据XX排序
    private List<ServiceCall> list;     //serviceProductList集合,用于和service层交互
    private Page page;

    public int getId() {
        return id;
    }

    public void setId(int ID) {
        this.id = ID;
    }

    public String getServiceCallNo() {
        return serviceCallNo;
    }

    public void setServiceCallNo(String serviceCallNo) {
        this.serviceCallNo = serviceCallNo;
    }

    public String getCustomer_ID() {
        return customer_ID;
    }

    public void setCustomer_ID(String customer_ID) {
        this.customer_ID = customer_ID;
    }

    public String getCustomer_Name() {
        return customer_Name;
    }

    public void setCustomer_Name(String customer_Name) {
        this.customer_Name = customer_Name;
    }

    public String getContact_ID() {
        return contact_ID;
    }

    public void setContact_ID(String contact_ID) {
        this.contact_ID = contact_ID;
    }

    public Integer getChannel_ID() {
        return channel_ID;
    }

    public void setChannel_ID(Integer channel_ID) {
        this.channel_ID = channel_ID;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCallUser_ID() {
        return callUser_ID;
    }

    public void setCallUser_ID(String callUser_ID) {
        this.callUser_ID = callUser_ID;
    }

    public String getCallUser_Name() {
        return callUser_Name;
    }

    public void setCallUser_Name(String callUser_Name) {
        this.callUser_Name = callUser_Name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCall_time() {
        return call_time;
    }

    public void setCall_time(Date call_time) {
        this.call_time = call_time;
    }

    public Date getReplay_time() {
        return replay_time;
    }

    public void setReplay_time(Date replay_time) {
        this.replay_time = replay_time;
    }

    public String getReplay_result() {
        return replay_result;
    }

    public void setReplay_result(String replay_result) {
        this.replay_result = replay_result;
    }

    public Date getClose_time() {
        return close_time;
    }

    public void setClose_time(Date close_time) {
        this.close_time = close_time;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getOrderdesc() {
        return orderdesc;
    }

    public void setOrderdesc(String orderdesc) {
        this.orderdesc = orderdesc;
    }

    public List<ServiceCall> getList() {
        return list;
    }

    public void setList(List<ServiceCall> list) {
        this.list = list;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }
}



  actionForm

package sboss.serviceCall.web.form;

import org.apache.struts.action.ActionForm;

/**
 * Created by IntelliJ IDEA.
 * User: Rao Lin
 * Date: 2010-12-10
 * Time: 17:18:27
 * To change this template use File | Settings | File Templates.
 */
public class ServiceCallForm  extends ActionForm{

   private int id ;// 表单ID
   private String     serviceCallNo     ; //   服务请求单编号
    private String  customer_ID         ; //  服务请求单客户id
    private String  customer_Name       ; // 服务请求单客户名称
   private String  contact_ID          ; //  服务请求单客户服务合同
    private Integer  channel_ID          ; //  服务商ID
    private String  telephone           ; //  服务请求人电话
   private String   address             ; //  服务请求人人地址
    private String  email              ; //   服务请求人人电子邮件
    private String  callUser_ID         ; //  服务请求人人ID
    private String  callUser_Name       ; //  服务请求人人名称
    private String  description         ; //  服务请求人内容
     private String call_time           ; // 服务请求人时间
    private String  replay_time        ; // 回访时间
     private String replay_result       ; // 回访结果
     private String close_time          ; // 服务请求人关闭时间
    private String  create_time         ; // 服务请求人创建时间
    private String  creator            ; //  服务请求人创建人
    private String  status              ; //  服务请求人告单状态
     private String      subject ;     // 主题

    public int getId() {
        return id;
    }

    public void setId(int ID) {
        this.id = ID;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getServiceCallNo() {


        return serviceCallNo;
    }

    public void setServiceCallNo(String serviceCallNo) {
        this.serviceCallNo = serviceCallNo;
    }

    public String getCustomer_ID() {
        return customer_ID;
    }

    public void setCustomer_ID(String customer_ID) {
        this.customer_ID = customer_ID;
    }

    public String getCustomer_Name() {
        return customer_Name;
    }

    public void setCustomer_Name(String customer_Name) {
        this.customer_Name = customer_Name;
    }

    public String getContact_ID() {
        return contact_ID;
    }

    public void setContact_ID(String contact_ID) {
        this.contact_ID = contact_ID;
    }

    public Integer getChannel_ID() {
        return channel_ID;
    }

    public void setChannel_ID(Integer channel_ID) {
        this.channel_ID = channel_ID;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCallUser_ID() {
        return callUser_ID;
    }

    public void setCallUser_ID(String callUser_ID) {
        this.callUser_ID = callUser_ID;
    }

    public String getCallUser_Name() {
        return callUser_Name;
    }

    public void setCallUser_Name(String callUser_Name) {
        this.callUser_Name = callUser_Name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCall_time() {
        return call_time;
    }

    public void setCall_time(String call_time) {
        this.call_time = call_time;
    }

    public String getReplay_time() {
        return replay_time;
    }

    public void setReplay_time(String replay_time) {
        this.replay_time = replay_time;
    }

    public String getReplay_result() {
        return replay_result;
    }

    public void setReplay_result(String replay_result) {
        this.replay_result = replay_result;
    }

    public String getClose_time() {
        return close_time;
    }

    public void setClose_time(String close_time) {
        this.close_time = close_time;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}



web 项面

page.jsp
  

<%@ include file="taglib.jsp" %>

<script language="javascript">

    var NEXT = 1;
    var PREV = -1;
            

    // default page form
    var formObject = document.forms[0];

    function next()
    {
        concatURL(formObject, NEXT);
	formObject.submit();
    }

    function prev()
    {
        concatURL(formObject, PREV);
	formObject.submit();
    }

    function gopage(page_no)
    {
        concatURL_page(formObject, page_no);
		formObject.submit();
    }


    function concatURL(formObject, flag)
    {
        var currentPage = ${pageInfo.currentPage} + flag * 1 ;
	var thisAction = formObject.action;
	thisAction += (-1 == thisAction.indexOf("?") ? "?" : "&" )
		+ "pageSize=${pageInfo.pageSize}" + "&currentPage=" + currentPage;
    formObject.action = thisAction;
    }

 	function concatURL_page(formObject, page_number)
    {
        var currentPage = page_number ;
	var thisAction = formObject.action;
	thisAction += (-1 == thisAction.indexOf("?") ? "?" : "&" )
		+ "pageSize=${pageInfo.pageSize}" + "&currentPage=" + currentPage;
    formObject.action = thisAction;
    }
    
    function pageSetForm(f)
    {
	formObject = f;
    }

    function setCustomePageTitle(customPageTitle)
    {
        document.all.custom_page_title.innerHTML = customPageTitle;
    }

</script>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td id="custom_page_title">&nbsp;</td>

        <td width="300">
        <c:if test="${not dont_show_total}">
	<bean:message key="page.info" arg0="${pageInfo.total}"
              arg1="${pageInfo.pageSize}" arg2="${pageInfo.currentPage}" 
              arg3="${pageInfo.totalPages}" />
        </c:if>
              &nbsp;
        </td>

<%--
        <td width="160">
            <fmt:message key="page.current_page"/>
	    <b><font color="red">${pageInfo.currentPage}</font></b>
	    /
	    <b><font color="red">
            <fmt:formatNumber value="${pageInfo.totalPages}" pattern="#####"/>
	    </font></b>
        </td>
--%>

        <td width="80">
	<c:if test="${pageInfo.currentPage > 1}">
			<a href="javascript:gopage('1')" ><fmt:message key="page.first" /></a>
            <a href="javascript:prev()"><fmt:message key="page.prev"/></a>
	</c:if>
	<c:if test="${pageInfo.currentPage <= 1}">
            <font color="#d6d6d6"><fmt:message key="page.first"/></font>
            <font color="#d6d6d6"><fmt:message key="page.prev"/></font>
	</c:if>
	&nbsp;
        </td>

        <td width="80">
	<c:if test="${pageInfo.currentPage < pageInfo.totalPages}">
            <a href="javascript:next()"><fmt:message key="page.next"/></a>
            <a href="javascript:gopage('${pageInfo.totalPages}')" ><fmt:message key="page.last" /></a>
	</c:if>
	<c:if test="${pageInfo.currentPage >= pageInfo.totalPages}">
            <font color="#d6d6d6"><fmt:message key="page.next"/></font>
            <font color="#d6d6d6"><fmt:message key="page.last"/></font>
	</c:if>
	&nbsp;
        </td>
    </tr>
</table>





相关页面调用
 <%--
  Created by IntelliJ IDEA.
  User: rl                                                 
  Date: 2010-12-11
  Time: 19:06:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../taglib.jsp" %>
<%@ include file="../header.jsp" %>
<link rel="stylesheet" href='${pageContext.request.contextPath}/config/public.css' type="text/css">
<link rel="stylesheet" href='${pageContext.request.contextPath}/config/index.css' type="text/css">
<script type="text/javascript" >
    function set_title() {
        top.frames.fraRightFrame.frames.fraContentBar.changeTitle('<fmt:message key="sc.menu"/>');
    }
    window.onload=set_title;
    function orderby(name){
        var orderbyname=document.forms[0].orderbyname.value;
        var orderdesc=document.forms[0].orderdesc.value;
        if(name==orderbyname){
            if(orderdesc==""){
                document.forms[0].orderdesc.value="desc";
            }else{
                document.forms[0].orderdesc.value="";
            }
        }else{
            document.forms[0].orderbyname.value=name;
            document.forms[0].orderdesc.value="desc";
        }
        document.forms[0].submit();
    }
    function create_form(){
        var myLeft = (screen.width-650)/2;
        var myTop = (screen.height-250)/2;
        window.open("ServiceCallAction.do?reqCode=show_add","","height=400, width=800, ,top=" + myTop + ",left=" + myLeft+",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
    }
    function search_form(){
    var status=document.forms[0].status.value;

        document.forms[0].submit();
    }
    function del_spm(id){
        if(confirm('<fmt:message key="fileManager.confirm.del" />')) {
            document.forms[0].action="ServiceCallAction.do?reqCode=deleteServiceCall&id="+id;
            search_form();
        }
    }
    function update_spm(id){
        var myLeft = (screen.width-650)/2;
        var myTop = (screen.height-250)/2;
        window.open("ServiceCallAction.do?reqCode=show_edit&id="+id,"","height=600, width=800, ,top=" + myTop + ",left=" + myLeft+",toolbar=no,scrollbars=2");
    }
    function authorized_spm(id){
        var myLeft = (screen.width-650)/2;
        var myTop = (screen.height-250)/2;
        alert("程序正在修改中。。。。"+id);
     //   window.open("ServiceCallAction.do?reqCode=show_authorized&id="+id,"","height=500, width=300, ,top=" + myTop + ",left=" + myLeft+",toolbar=no,scrollbars=2");
    }

</script>
<body style="margin-top:-8px;">
<div class="row" >
  <div class="row_table_top">
     <div class="row_table_top_left"> <img src="${pageContext.request.contextPath}/images/point_down.gif" /><fmt:message key="sc.query"/></div>
  </div>
 <div class="row_table_middle" id="tab1" >

      <html:form action="/ServiceCallAction.do?reqCode=showIndex"  method="post" styleClass="FORM">
          <html:hidden property="orderbyname" value="${orderbyname}"/>
            <html:hidden property="orderdesc" value="${orderdesc}"/>
            <html:hidden property="reqCode" value="showIndex"/>

            <div class="boxform">
                <ul>
                    <li style="width:100%;padding-left:10px;">
                        <fmt:message key="sc.type"/>
                      <html:select property="status"  style="width:145" value="${status}">
                                  <html:option value="">全部</html:option>
                                   <html:option value="">新建</html:option>
                           <html:option value="">处理中</html:option>
                          <html:option value="">待确认</html:option>
                           <html:option value="">已关闭</html:option>
                            <%--<html:optionsCollection name="1" value="id" label="name"/> --%>
                        </html:select>

                        <html:button styleClass="button" property="search" onclick="search_form()">
                            <fmt:message key='spm.list.select'/>
                        </html:button>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <html:button styleClass="button" property="create" onclick="create_form()">
                            <fmt:message key='spm.list.add'/>
                        </html:button>
                    </li>
                </ul>
            </div>

            <div class="row_paging" style="background:none;border:none">
                <jsp:include page="../page.jsp"/>
                <script language="javascript">
                    pageSetForm(document.forms[0]);
                </script>
            </div>
            <table class="table3" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table class="table3_1" cellpadding="0" cellspacing="0">
                            <tr>
                                <th>
                                    <fmt:message key="spm.list.numbers"/>
                                </th>
                                <th>
                                      <fmt:message key="sc.list.name"/>
                                    </a>
                                </th>
                                <th>
                                    <a href="#" onclick="">
                                        <b><fmt:message key="sc.type" /></b>
                                    </a>
                                    <c:if test="${orderbyname=='status'}">
                                        <c:if test="${orderdesc=='desc'}">
                                            <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                        <c:if test="${orderdesc==''}">
                                            <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                    </c:if>
                                </th>
                                <th>
                                        <a href="#" onclick="">
                                        <b><fmt:message key="sc.create.name" /></b>
                                       <c:if test="${orderbyname=='creator'}">
                                        <c:if test="${orderdesc=='desc'}">
                                            <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                        <c:if test="${orderdesc==''}">
                                            <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                    </c:if>
                                </th>
                                <th>
                                    <a href="#" onclick="orderby('create_time');">
                                        <b><fmt:message key="spm.list.creatTime" /></b>
                                    </a>
                                    <c:if test="${orderbyname=='create_time'}">
                                        <c:if test="${orderdesc=='desc'}">
                                            <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                        <c:if test="${orderdesc==''}">
                                            <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" "  width="9" height="9" border="0" />
                                        </c:if>
                                    </c:if>
                                </th>
                                <th>
                                    <fmt:message key="spm.list.do"/>
                                </th>
                            </tr>
                              
                            <c:forEach var="servicec"  items="${serviceCallList}" varStatus="status">


                                <c:if test="${status.count%2==0}">
                                    <tr  class="double">
                                </c:if>
                                <c:if test="${status.count%2!=0}">
                                    <tr>
                                </c:if>
                                <td>${status.count}</td>
                                <td><div align="left">${servicec.subject} </div></td>
                                <td style="text-align:left;"><div align="center">${servicec.status}</div></td>
                                <td><div align="center"><span style="text-align:left;">
                                      ${servicec.creator}
                                    </span></div></td>
                                <td>
                                  <fmt:formatDate value="${servicec.create_time}" pattern="yyyy-MM-dd HH:mm:ss" />
                                </td>

                                <td>
                                    <!-- 授权-->
                                    <a href="javascript:authorized_spm(${servicec.id})" title="<fmt:message key='doc.grant'/> ">
                                        <img src="${pageContext.request.contextPath}/images/ry.gif" />
                                    </a>
                                    <!-- 修改-->
                                    <a href="javascript:update_spm(${servicec.id})" title="<fmt:message key="spm.list.update"/>">
                                        <img src="${pageContext.request.contextPath}/images/rtop.gif" />
                                    </a>
                                    <!-- 删除-->
                                    <a href="javascript:del_spm(${servicec.id})" title="<fmt:message key="spm.list.delet"/>">
                                        <img src="${pageContext.request.contextPath}/images/delete.gif" />
                                    </a>
                                </td>

                                </tr>

                            </c:forEach>
                            <c:if test="${countRecord == 0}">
                                <tr>
                                    <td colspan="7">
                                        <font color="red"><fmt:message key="spm.list.no"/></font>
                                    </td>
                                </tr>
                            </c:if>
                        </table></td>
                </tr>
            </table> 
        </html:form>
 </div>
 </div>
<%@ include file="../footer.jsp" %>



以上是一些分页的部分代码。。

你可能感兴趣的:(DAO,Hibernate,jsp,struts,idea)