<html:form action="/recei?action=getAll">
<p align="center">
第${page},共有${pageCount}
<html:link action="/recei?action=getAll&page=1">[首页]</html:link>
<html:link action="/recei?action=getAll&page=${page-1}">[上一页]</html:link>
<html:link action="/recei?action=getAll&page={page+1}">[下一页]</html:link>
<html:link action="/recei?action=getAll&page=pageCount">[尾页]</html:link>
转到
<input type="text" name="page" size="1" id="page" value="${page}">
每页显示
<input type="text" name="size" size="1" id="size" value="${size}">
<input type="submit" name="go" value="GO">
</p>
</html:form>
分析下:page和pageCount是自己在页面定义的两个变量,page代表你要显示的页数,pageCount表示总页,size表示你每页要显示多小条数据。再在对应的Action里面写查询方法。其他 的很简单了。
<p align="center">
第${page},共有${pageCount}
<html:link action="/recei?action=getAll&page=1">[首页]</html:link>
<html:link action="/recei?action=getAll&page=${page-1}">[上一页]</html:link>
<html:link action="/recei?action=getAll&page={page+1}">[下一页]</html:link>
<html:link action="/recei?action=getAll&page=pageCount">[尾页]</html:link>
转到
<input type="text" name="page" size="1" id="page" value="${page}">
每页显示
<input type="text" name="size" size="1" id="size" value="${size}">
<input type="submit" name="go" value="GO">
</p>
</html:form>
分析下:page和pageCount是自己在页面定义的两个变量,page代表你要显示的页数,pageCount表示总页,size表示你每页要显示多小条数据。再在对应的Action里面写查询方法。其他 的很简单了。
不论用jsf还是struts2原理都一样,只是标签名变下。
<p align="center">
第${page},共有${pageCount}
<html:link action="/recei?action=getAll&page=1">[首页] </html:link>
<html:link action="/recei?action=getAll&page=${page-1}">[上一页] </html:link>
第<html:link action="/recei?action=getAll&page=${page}"></html:link>
<html:link action="/recei?action=getAll&page={page+1}">[下一页] </html:link>
共有<html:link action="/recei?action=getAll&page=${pageCount}">页</html:link>
<html:link action="/recei?action=getAll&page=pageCount">[尾页] </html:link>
转到
<input type="text" name="page" size="1" id="page" value="${page}">
每页显示
<input type="submit" name="go" value="GO">
</p>
</html:form>
是这样吗?
<p align="center">
第${page},共有${pageCount}
<html:link action="/recei?action=getAll&page=1">[首页] </html:link>
<html:link action="/recei?action=getAll&page=${page-1}">[上一页] </html:link>
<!-- 只显示6页 -->
<c:forEach items="${pages}" var="i">
<a href="PageServlet?p=${i}">${i}</a>
</c:forEach>
<html:link action="/recei?action=getAll&page={page+1}">[下一页] </html:link>
<html:link action="/recei?action=getAll&page=pageCount">[尾页] </html:link>
转到
<input type="text" name="page" size="1" id="page" value="${page}">
<input type="submit" name="go" value="GO">
</p>
</html:form>
<!--Action里的代码-->
String p = request.getParameter("page");
if (null == p) {
p = "1"; }
String s = request.getParameter("size");
if (s == null) {
s = "3";
}
int pp = Integer.parseInt(p);
int size = Integer.parseInt(s);
// 得到总页数
int pageCount = sendbiz.getPageCount(size);
// 如果越界
if (pp < 1) {
pp = 1;
} else if (pp > pageCount) {
pp = pageCount;
}
//显示页数放到集合中
List pages = new ArrayList();
int start = 1;
if (page==1) start = 1; //第一页
else if (page%6==0) start = page+1;
else if (page%6==1) start = page-6;
else start = page/6*6+1;
for (int i=start;i<start+6 && i<=count;i++)
pages.add(i);
request.setAttribute("pages", pages);
// 查询具体显示第几页,每页显示几条信息
List pages= 对象.getPage(pp, size);
request.getSession().setAttribute("page", pp);
request.getSession().setAttribute("pageCount", pageCount);
request.getSession().setAttribute("pages", pages);
return mapping.findForward("页面");
还不懂我就晕了~~~~~~