Jgrid列表data2


<%@page contentType="text/xml;charset=UTF-8"%>
<%@ page import="java.util.HashMap,java.text.ParseException,tools.*"%>
<%@page import="java.sql.Connection,java.sql.DriverManager,java.sql.PreparedStatement,java.sql.ResultSet,java.sql.SQLException"%>
<%
//request.setCharacterEncoding("gb2312");
String pagenum=request.getParameter("page");
String limit=request.getParameter("limit");
String sidx =request.getParameter("sidx");
//String sord =request.getParameter("sord");
String _search=request.getParameter("_search");
String url="select id,channel_id,channel_name,channel_addr from game.T_GAME_WAP_CHANNEL_ADDR order by id";

if(_search==null||"false".equals(_search)){
url= "select id,channel_id,channel_name,channel_addr from game.T_GAME_WAP_CHANNEL_ADDR order by id";
}else{
String searchField=request.getParameter("searchField");
String searchString=request.getParameter("searchString");
if(searchString==null||"".equals(searchString)){
url= "select id,channel_id,channel_name,channel_addr from game.T_GAME_TYPE order by id";
}else{
if("channel_id".equals(searchField)){
url="select id,channel_id,channel_name,channel_addr from game.T_GAME_WAP_CHANNEL_ADDR where channel_id like '%"+searchString+"%' order by id";
}else if("channel_name".equals(searchField)){
url="select id,channel_id,channel_name,channel_addr from game.T_GAME_WAP_CHANNEL_ADDR where channel_name like '%"+searchString+"%' order by id";
}
}

}


if(sidx==null) sidx="1";
if(pagenum==null) pagenum="1";
if(limit==null) limit="25";
int total_result_count = 0;
int total_page_count = 0;
int per_page = Integer.parseInt(limit);
int cur_page_num = Integer.parseInt(pagenum);
java.util.LinkedList<HashMap> result = new java.util.LinkedList<HashMap>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rst = null;
try {
conn = getConnection("jdbc/game");
//conn = mysql();
stmt = conn.prepareStatement("select count(*) from game.T_GAME_WAP_CHANNEL_ADDR");

rst = stmt.executeQuery();
rst.next();
total_result_count = rst.getInt(1);

if (total_result_count > 0) {
total_page_count = (total_result_count / per_page);
}

if ((total_result_count % per_page) > 0) {
total_page_count++;
}
stmt = conn.prepareStatement(url + " limit ?,?");
stmt.setInt(1, (cur_page_num-1) * per_page);
stmt.setInt(2, per_page);
rst = stmt.executeQuery();
while(rst.next()){
HashMap<String,String> one=new HashMap<String,String>();
int count =rst.getMetaData().getColumnCount();
for(int i=0;i<count;i++){
one.put(rst.getMetaData().getColumnName(i+1), rst.getString(i+1)==null?"":rst.getString(i+1));
}
result.add(one);
}
//out.print("result: "+result);
%>
<rows>
<page><%=pagenum%></page>
<total><%=total_page_count%></total>
<records><%=total_result_count%></records>
<%for(int i=0;i<result.size();i++){
HashMap map=result.get(i);
%>
<row id='<%=map.get("id")%>'>
<cell><%=map.get("id")%></cell>
<cell><%=map.get("channel_id")%></cell>
<cell><%=map.get("channel_name").toString().replace("\"", "").replace(":", "").replace(":", "").replace("-", "").replace("'", "").replace("&", "").replace("<", "").replace(">", "")%></cell>
<cell><%=map.get("channel_addr")%></cell>
</row>
<%}%>
</rows>
<%
} catch (Exception e) {
e.printStackTrace();
} finally {
if (rst != null) {
try {
rst.close();
rst = null;
} catch (SQLException ex) {
rst = null;
}
}
if (stmt != null) {
try {
stmt.close();
stmt = null;
} catch (SQLException ex) {
stmt = null;
}
}
if (conn != null) {
try {
conn.close();
conn = null;
} catch (SQLException ex) {
conn = null;
}
}
}
%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值