info.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
          "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="testInfoMap">
    
    <statement
        id="getInfo"
        parameterClass="demo.domain.TestInfo"
        resultClass="demo.domain.TestInfo">
        select top 1 * 
        from test_info
        
    </statement>
    
    <statement
        id="getInfos"
        
        resultClass="demo.domain.TestInfo">
        <!-- select top #pagesize# * 
        from areacode
        where areacodeid not in 
        (select top (#currpage# - 1)*#pagesize# from areacode order by areacodeid)
        order by areacodeid   
        parameterClass="cn.limitoa.util.page.PageManager"-->
        
        select top $pagesize$ t1.info_id as info_id, t1.type_id as type_id, t1.info_name as info_name, t1.info_content as info_content,t2.type_name as type_name 
    from test_info t1,test_type t2 where t1.info_id not in(select top $currpage$ info_id from test_info order by info_id) and 
     t2.type_id=t1.type_id  and t2.type_name like '%$type_name$%'
     
    </statement>
    
    <statement
        id="getCounts"
        resultClass="java.lang.String">
        select count(*) 
        from test_info
    </statement>
</sqlMap>
给分啊,兄弟们!!

解决方案 »

  1.   

    ibatis数据库分页二:
    package demo.domain;public class TestInfo extends TestType{    /**
         * This field was generated by Abator for iBATIS. This field corresponds to the database column test_info.info_id
         * @abatorgenerated  Sat Dec 16 21:41:08 CST 2006
         */
        private Integer info_id;
        /**
         * This field was generated by Abator for iBATIS. This field corresponds to the database column test_info.type_id
         * @abatorgenerated  Sat Dec 16 21:41:08 CST 2006
         */
        private Integer type_id;
        /**
         * This field was generated by Abator for iBATIS. This field corresponds to the database column test_info.info_name
         * @abatorgenerated  Sat Dec 16 21:41:08 CST 2006
         */
        private String info_name;
        /**
         * This field was generated by Abator for iBATIS. This field corresponds to the database column test_info.info_content
         * @abatorgenerated  Sat Dec 16 21:41:08 CST 2006
         */
        private String info_content;
        private Integer currpage;
      private Integer pagesize;
    public String getInfo_content() {
    return info_content;
    }
    public void setInfo_content(String info_content) {
    this.info_content = info_content;
    }
    public Integer getInfo_id() {
    return info_id;
    }
    public void setInfo_id(Integer info_id) {
    this.info_id = info_id;
    }
    public String getInfo_name() {
    return info_name;
    }
    public void setInfo_name(String info_name) {
    this.info_name = info_name;
    }
    public Integer getType_id() {
    return type_id;
    }
    public void setType_id(Integer type_id) {
    this.type_id = type_id;
    }
    public Integer getCurrpage() {
    return currpage;
    }
    public void setCurrpage(Integer currpage) {
    this.currpage = currpage;
    }
    public Integer getPagesize() {
    return pagesize;
    }
    public void setPagesize(Integer pagesize) {
    this.pagesize = pagesize;
    }
        
    }
    <%@ page language="java" contentType="text/html;charset=utf-8"%>
    <%@ page import="util.SqlConfigClient"%>
    <%@ page import="com.ibatis.sqlmap.client.SqlMapClient" %>
    <%@ page import="demo.domain.TestInfo" %>
    <%@ page import="util.PageManager" %>
    <%@ page import="java.util.List" %>
    <%@ page import="java.util.ArrayList" %>
    <%@ page import="java.util.Iterator" %><%
        SqlMapClient sqlMap=SqlConfigClient.getSqlMapInstatce();
        TestInfo testInfo = new TestInfo();
        PageManager pageManager = new PageManager();
        List testInfoList = new ArrayList();
        
        String areaCounts = String.valueOf(sqlMap.queryForObject("testInfoMap.getCounts"));
        int currpage=1;
        int pagesize=20;
        
        pageManager.setCurrpage(currpage);
        pageManager.setPagesize(pagesize);
        pageManager.setCounts(Integer.parseInt(areaCounts));
        
          String MyURL = "index.jsp"; //count is record sum      //取得最大页数
          if (pageManager.getCounts() % pageManager.getPagesize() == 0) {
            pageManager.setMaxpage(pageManager.getCounts() / pageManager.getPagesize());
          }else {
            pageManager.setMaxpage((int)(pageManager.getCounts() / pageManager.getPagesize()) + 1);
          }
          
          //根据是否带有参数来取得当前页,定位到的记录,及取得的数据集的最大返回数
          if (request.getParameter("currpage") != null) {
           int tmppage = 0;
            try {
              tmppage = Integer.parseInt(request.getParameter("currpage"));
              if (tmppage < 1) {
                pageManager.setCurrpage(1);
              }
              if (tmppage > pageManager.getMaxpage()) {
                pageManager.setCurrpage(pageManager.getMaxpage());
              }
              pageManager.setCurrpage(tmppage);
            }catch (Exception e) {}
          }
         
          String selStr = "<select name=currpage>";
          selStr += "<option value="+pageManager.getCurrpage()+">" + pageManager.getCurrpage() + "</option>";
          for (int i = 1; i <= pageManager.getMaxpage(); i++) {
            selStr += "<option value="+i+">" + i + "</option>";
          }
          selStr +="</select>";
          
         testInfo.setCurrpage(new Integer((pageManager.getCurrpage()-1)*pageManager.getPagesize()));
         testInfo.setPagesize(new Integer(pageManager.getPagesize()));
         testInfo.setType_name("二手");
         System.out.println(testInfo.getCurrpage());
         System.out.println(testInfo.getPagesize());
         
         
         testInfoList =sqlMap.queryForList("testInfoMap.getInfos",testInfo);
    %>
    <html>
    <head>
    <link href="/CSS/Style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="98%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CFE2FB">
    <tr>
    <td colspan="3" height="26" align="left" background="/Images/EditorBar.gif">
    信息列表
    </td>
    </tr>
    <tr height="10">
    <td colspan="3" valign="top">
    <!-- <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CFE2FB">
    <form action="codeinfo.jsp" method="post" name="saveForm">
    <tr>
    <td align="left" width="9%" class="FntIndent6">
    请填写所查询地区:
    <input type="text" size="28" name="area" class="InputLightBlue">
    <img src="/Images/buttons/go_go.gif" style="cursor: hand" onclick="CheckForm()">
    </td>
    </tr>
    </form>
    </table>-->
    </td>
    </tr>
    <tr>
    <td colspan="3" valign="top">
    <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CFE2FB">
    <tr height="20">
    <td align="left" width="25%" bgcolor="#C2DCEE" class="FntIndent6">
    <span class="BlueTxtTreeBig">分类名</span>
    </td>
    <td align="left" width="12%" bgcolor="#C2DCEE" class="FntIndent6">
    <span class="BlueTxtTreeBig">标题</span>
    </td>
    </tr> <%
      if(testInfoList!=null){
       Iterator itr = testInfoList.iterator();
       while(itr.hasNext()){
       testInfo = (TestInfo)itr.next();
       out.print("<tr height='10'>");
       out.print("<td align=left>"+testInfo.getType_name()+"</td>");
       out.print("<td align=left>"+testInfo.getInfo_name()+"</td>");
      
       out.print("</tr>");
       }
      }
    %>
    <%
          out.print("<tr>");
          out.print("<td colspan='3' class='td_bg_qhs' align='right'>第" + pageManager.getCurrpage()
                  + "页-共" + pageManager.getMaxpage() + "页 -共" + pageManager.getCounts() + "条信息‖<a href=" + MyURL
                  + ">首页</a>‖<a href=" + MyURL + "?currpage=" + (pageManager.getCurrpage() - 1)
                  + ">上一页</a> ‖<a href="+MyURL+"?currpage=" + (pageManager.getCurrpage() + 1)
                  + ">下一页</a>‖<a href=" + MyURL + "?currpage=" + pageManager.getMaxpage()
                  + ">尾页</a>"+selStr+"<img src='/Images/buttons/go_go.gif' style='cursor: hand' onclick='go()'></tr>");
        %>
        </table>
        </td>
        </tr>
    </table>
    </body>
    </html><script language=javascript>
    <!--
    function CheckForm(){
    if(document.all("area").value==""){
    alert("请填写所查询地区!");
    document.all("area").focus();
    return false;
    }else{
    saveForm.submit();
    return true;
    }
    }function go(){
    var currpage = document.all("currpage").value;
    window.navigate("index.jsp?currpage="+currpage);
    }
    //-->
    </script>
      

  2.   

    ibatis数据库分页三:
    package util;public class PageManager {
      private int currpage;
      private int pagesize;
      private int maxpage;
      private int counts;
      
      public PageManager(){
      }
      
      public int getCurrpage() {
        return currpage;
      }   public void setCurrpage(int currpage) {
        this.currpage = currpage;
      }   public int getPagesize() {
        return pagesize;
      }   public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
      }   public int getMaxpage() {
        return maxpage;
      }   public void setMaxpage(int maxpage) {
        this.maxpage = maxpage;
      }   public int getCounts() {
        return counts;
      }   public void setCounts(int counts) {
        this.counts = counts;
      }
    }