📄 paginationresult_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import pagination.*;
import java.sql.*;
import java.util.*;
public final class PaginationResult_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.List _jspx_dependants;
public Object getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=GBK");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
out.write("<html>\r\n");
out.write("\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<meta http-equiv=\"Content-Language\" content=\"zh-cn\">\r\n");
out.write("<meta http-equiv=\"pragma\" content=\"no-cache\">\r\n");
out.write("<meta name=\"Author\" content=\"YuLimin\">\r\n");
out.write("<meta name=\"Description\" content=\"Pagination\">\r\n");
out.write("<meta name=\"Keywords\" content=\"Pagination\">\r\n");
out.write("<title>数据库分页</title>\r\n");
out.write("<style type=\"text/css\">\r\n");
out.write("<!--\r\n");
out.write(".Pagination{font: 12pt;}\r\n");
out.write("//-->\r\n");
out.write("</style>\r\n");
out.write("<script language=\"javascript\" type=\"text/javascript\" src=\"Pagination.js\"></script>\r\n");
out.write("</head>\r\n");
out.write("\r\n");
out.write("<body bgcolor=\"#ffffff\">\r\n");
String Query = request.getParameter("tQuery");
String tNumber = request.getParameter("tNumber");
if(Query != null)
{
//Post方式时要转码一下Get方式不用转码
if(request.getMethod().equalsIgnoreCase("Post"))
{
Query = new String(Query.getBytes("ISO-8859-1"),"GBK");
}
}
if(tNumber == null)
{
tNumber = "0";
}
out.write("\r\n");
out.write("<form name=\"formPagination\" action=\"PaginationResult.jsp\" method=\"post\">\r\n");
out.write("\t<p align=\"center\">姓名:<input name=\"tQuery\" value=\"");
out.print((Query == null ? "" : Query));
out.write("\" ondblclick=\"this.value='俞黎敏'\">\r\n");
out.write("\t</p>\r\n");
out.write("\t<p align=\"center\"><input type=\"submit\" value=\"查 询\" name=\"tSubmit\"> <input type=\"reset\" value=\"重 置\" name=\"tReset\"></p>\r\n");
out.write("<table border=\"1\" width=\"100%\">\r\n");
out.write("<tr>\r\n");
out.write(" <td>ID</td>\r\n");
out.write(" <td>姓名</td>\r\n");
out.write(" <td>性别</td>\r\n");
out.write(" <td>手机</td>\r\n");
out.write(" <td>地址</td>\r\n");
out.write(" <td>备注</td>\r\n");
out.write("</tr>\r\n");
Connection conn = null;
try
{
String strSQL = (Query == null ? "" : " where name like '%" + Query + "%'");
if(Query != null)
{
out.println("搜索:" + Query);
out.println("<br>");
//out.println("SQL:select * from Personinfo" + strSQL);
out.println("<br>");
}
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/Pagination?autoReconnect=true&useUnicode=true&characterEncoding=GB2312","root","root");
PaginationDAO dao = new PaginationDAO()
{
public Object getResultSetData(ResultSet rs) throws PaginationException
{
Vector v = new Vector();
try
{
v.add(rs.getString(1));
v.add(rs.getString(2));
v.add(rs.getString(3));
v.add(rs.getString(4));
v.add(rs.getString(5));
v.add(rs.getString(6));
}
catch(SQLException ex)
{
ex.printStackTrace();
throw new PaginationException(ex.getMessage());
}
return v;
}
};
Pagination p = Pagination.getPage("select count(*) from Personinfo" + strSQL,"select * from Personinfo" + strSQL,conn,dao,5,request);
Iterator itr = p.getData().iterator();
//out.println(p.buildJS("parent.Query.formPagination"));
out.println(p.getPaginationHTMLCode("formPagination"));
//int count = 0;
while(itr.hasNext())
{
Vector v = (Vector)itr.next();
//count++;
out.println("\t\t<tr>");
//out.println("\t\t\t<td>" + count + "</td>");
for(int i = 0;i < v.size();i++)
{
out.println("\t\t\t<td>" + (String)v.elementAt(i) + "</td>");
}
out.println("\t\t</tr>");
//out.println(p.getPaginationHTMLCode("formPagination"));
}
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(conn !=null)
{
try
{
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
out.write("\r\n");
out.write("</table>\r\n");
out.write("</form>\r\n");
out.write("</body>\r\n");
out.write("\r\n");
out.write("</html>\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -