JSP的分页实现!
package com.gc.tool;
import java.util.ArrayList;
import java.util.List;
public class MyPagination {
private int recordCount = 0;
private int pagesize = 0;
private int maxPage = 0;
private int page = 0;
public int getMaxPage(){
int maxPage = (recordCount%pagesize == 0)?(recordCount/pagesize):(recordCount/pagesize+1);
return maxPage;
}
public int getPage(String str){
if(str == null){
str = "0";
}
int page = Integer.parseInt(str);
if(page<1){
page = 1;
}else{
if(page > maxPage){
page = maxPage;
}
}
return page;
}
@SuppressWarnings("unchecked")
public List getInitPage(List list, String page,int pageSize){
this.recordCount = list.size();
this.pagesize = pageSize;
this.maxPage = getMaxPage();
this.page = getPage(page);
List<Object> newList = new ArrayList<Object>();
相关文档:
1.jsp:include标签是在执行时才对加载的文件进行处理,因此Jsp页面和它所加载的文件在逻辑和语法上都是独立的,如果对加载文件进行修改,那么运行时可以看到所加载文件修改后的结果
2.而用include指令加载文件时,是将加载文件和Jsp页面合并成一个新的Jsp页面后,发送给Jsp引擎进行处理的,因此如果加载文件发生变化,则必 ......
request对象是javax.servlet.HttpServletRequest类的一个子类对象,当客户端请求一个Jsp页面是,Jsp容器会将客户端的请求信息包装在这个对象中;该对象中的常用方法如下:
getParameter(String name):以字符串的形式返回客户端传来的某一个请求参数的值,参数名由name指定
getParameterNames() ......
该对象是javax.servlet.ServletResponse类的实例,其作用刚好与request对象相反,request对象是包含了客户请求的有关信息,而response对象是包含了响应客户请求的有关信息;常用方法如下
addCookie(Cookie c):添加一个Cookie对象,用来保存客户端的用户信息
sendRedirect(URL):将当前客户端的 ......
Exception对象是用来处理Jsp页面文件在执行时所有发生的错误和异常;Jsp页面文件必须在isErrorPage=true的情况下才可以使用该对象;该对象一般配合Page指令一起使用,通过指定某个页面为错误处理页面,把所有的错误都集中到那个页面进行处理,可以使整个系统的性能得到加强;常用方法如下
getMes ......
I used Eclipse to try the google app engine demo project: guestbook.
when i create a *.jsp file in the WAR directory,the error information appear:
"Your Web Application Project must be configured to use a JDK in order to use JSPs."
solution:
It is because Eclipse put the JRE to the JRE directory ......