String str = request.getParameter("str");
if(str==null){
str = "";
}
获取分页文本框关键字
int start = (pageIndex-1)*pageSize+1;
int end = pageIndex*pageSize;
String sql = "select * from(select a.*,rownum mid from newst a where ntitle like '%"+str+"%')b where mid>=? and mid<=?";
ps = con.prepareStatement(sql);
ps.setInt(1,start);
ps.setInt(2, end);
rs = ps.executeQuery();
通过SQL语句进行模糊查询,并刷新分页
String id = request.getParameter("tid");
String countSql = "select count(*) from newst";
String pageSql = "select * from (select a.*,rownum mid from newst a)b where mid>=? and mid<=?";
int tid = 1;
if(id!=null){
tid = Integer.valueOf(id);
countSql = "select count(*) from newst where tid="+tid;
pageSql = "select * from (select a.*,rownum mid from newst a where tid="+tid+")b where mid>=? and mid<=?";
}
接收新闻主题,并模糊查询,根据主题查询刷新页面