<%@ page language="java" import="java.util.*, dbBean.DBDao" pageEncoding="UTF-8"%>
<%
String pageid = request.getParameter("page");
String rows = request.getParameter("rows");
String sname_filter = request.getParameter("sname_filter");
String sql = null;
List<Object> args = new ArrayList<Object>();
Integer currentpage = (pageid == null || pageid.equals("0"))? 1 : Integer.parseInt(pageid);
Integer pagesize = Integer.parseInt(((rows == null || rows.equals("0")) ? application.getAttribute("rows").toString() : rows));
Integer offset = (currentpage - 1) * pagesize;
String sqlCount = "select count(*) from student";
DBDao db = new DBDao();
if(sname_filter == null || sname_filter.trim().equals(""))
{
sql = "select student.id, sname, nation, item, format(birth,'yyyy-mm-dd') as birth, score, birth, address from student, nation where nation.id=nation limit ?,?";
}
else
{
sql = "select student.id, sname, nation, item, birth, score, birth, address from student, nation where nation.id=nation and sname like ? limit ?,?";
args.add(sname_filter + "%");
}
args.add(offset);
args.add(pagesize);
out.print(db.getDataGridJson(sqlCount, null, sql, args));
%>