在jsp中使用分页自定义标签库
<pf:page-flip serverName="CustomerArchivePFServer">
<pf:url value="pageFlipTest.do">
<pf:parameter name="dept4_id" value="028002A2"/>
<pf:parameter name="flag_bigcust" value="否"/>
</pf:url>
<pf:navigator>
第<pf:page-no/>页
共<pf:page-count/>页
【<pf:first-page>首页</pf:first-page>】
【<pf:previous-page>上一页</pf:previous-page>】
【<pf:next-page>下一页</pf:next-page>】
【<pf:last-page>尾页</pf:last-page>】
<pf:jump-to-page/>
</pf:navigator>
</pf:page-flip>
后台代码
public
ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws
IOException, ServletException
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
String pageNo = request.getParameter("pageNo");
String pageSize = request.getParameter("pageSize");
String sql = "select a.custor_id, a.custname, b.eptype2_nm, c.volt_nm " +
"from dw_f_custor a, dw_d_eptype2 b, dw_d_volt c " +
"where a.eptype2_id = b.eptype2_id " +
"and a.volt_id = c.volt_id " +
"and a.dept4_id = ? and flag_bigcust = ?";
if(pageNo == null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
pageNo = "1";
}
if(pageSize == null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
pageSize = "20";
}
Connection dbConnection = null;
try
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
dbConnection = DbConnectionFactory.getConnection();
PageFlipServer server = new PageFlipServer(Integer.parseInt(pageNo),Integer.parseInt(pageSize),sql);
String p1Value = request.getParameter("dept4_id");
String p2Value = request.getParameter("flag_bigcust");
server.addQuerySQLParameter(1,p1Value);
server.addQuerySQLParameter(2,p2Value);
RowSet rs = server.execute(dbConnection);
if(rs != null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
Collection customerArchives = new ArrayList();
while(rs.next())
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
HashMap row = new HashMap();
row.put("custor_id",rs.getString("custor_id"));
row.put("custname",rs.getString("custname"));
row.put("eptype2_nm",rs.getString("eptype2_nm"));
row.put("volt_nm",rs.getString("volt_nm"));
customerArchives.add(row);
}
request.setAttribute("customer_archives",customerArchives);
}
request.setAttribute("CustomerArchivePFServer",server);
}
catch(DbConnectionCreateException e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
e.printStackTrace();
throw new ServletException(e);
}
catch(PageFlipFatalException e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
e.printStackTrace();
throw new ServletException(e);
}
catch(SQLException e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
e.printStackTrace();
throw new ServletException(e);
}
finally
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
try
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
dbConnection.close();
}
catch(SQLException e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
throw new ServletException(e);
}
}
return mapping.findForward("success");
}
效果图
![]()