在JSP中经常要用到查询数据库中的数据,同常我们的做法是使用SQL语句“select * from tablename order by id desc”,这样的做法有一个缺点,当数据库很大的时候查询的速度会变的很慢,在ASP中有一种方法 "select top "&recpage&" * from tablename where id not in (select top "&(recpage*(currentpage-1))&" id from products order by id desc) order by id desc"其中recpage为每页显示个数, currentpage为当前页数.不过在MYSQL数据库中没有“select top * " 语句,而可以代替的语句是”select * from tablename limit position, counter “position 指示从哪里开始查询,如果是0则是从头开始,counter 表示查询的个数,通过JSP+JAVA查询数据库,查询获取的数据暂时存放在内存中在JSP中通过调取JAVA类,直接从内存中提取数据,速度有了很大提高。