oracle+servlet+extjs4 分页表格布局示例代码
Log.java
package com.example.entity; import java.util.Date; public class Log { private int id;
private Date timestamp;
private String module;
private String function;
private String method;
private String userId;
private String userName;
private String localIp;
private String remoteIp;
private int type;
private String fileName;
private int fileSize;
private String params;
private int success;
private String error;
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public int getFileSize() {
return fileSize;
}
public void setFileSize(int fileSize) {
this.fileSize = fileSize;
}
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLocalIp() {
return localIp;
}
public void setLocalIp(String localIp) {
this.localIp = localIp;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getRemoteIp() {
return remoteIp;
}
public void setRemoteIp(String remoteIp) {
this.remoteIp = remoteIp;
}
public int getSuccess() {
return success;
}
public void setSuccess(int success) {
this.success = success;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
} }
LogDAO.java
package com.example.DAO; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import com.example.entity.Log; public class LogDAO { private static Connection getConn() {
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@192.168.97.201:1521:fznop";
String username = "bi_swxt";
String password = "swxt2013";
Connection conn = null;
try {
Class.forName(driver);
// new oracle.jdbc.driver.OracleDriver();
conn = DriverManager.getConnection(url, username, password);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
} return conn;
} public static List<Log> findAll(int start, int limit) {
int s = start +1;
int e = start + limit;
Connection conn = getConn();
String sql = "select id,timestamp,module,function,method,user_id,user_name,local_ip," +
"remote_ip,type,file_name,file_size,params,success,error from (select r.*, rownum as d " +
"from (select * from system_log) r where rownum <= " +e + ") where d >= " +s;
PreparedStatement pstmt;
List<Log> list = new ArrayList<Log>(); try {
pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Log log = new Log();
log.setId(rs.getInt(1));
log.setTimestamp(rs.getDate(2));
log.setModule(rs.getString(3));
log.setFunction(rs.getString(4));
log.setMethod(rs.getString(5));
log.setUserId(rs.getString(6));
log.setUserName(rs.getString(7));
log.setLocalIp(rs.getString(8));
log.setRemoteIp(rs.getString(9));
log.setType(rs.getInt(10));
log.setFileName(rs.getString(11));
log.setFileSize(rs.getInt(12));
log.setParams(rs.getString(13));
log.setSuccess(rs.getInt(14));
log.setError(rs.getString(15));
list.add(log);
}
rs.close();
pstmt.close();
conn.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
return list;
} public static int getTotal(){
Connection conn = getConn();
String sql = " select count(*) from system_log";
PreparedStatement pstmt;
int total = 0;
try {
pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
if(rs.next()){
total= rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return total;
}
}
LogServlet.java
package com.example.servlet; import java.io.IOException;
import java.io.PrintWriter;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.example.DAO.LogDAO;
import com.example.entity.Log; public class LogServlet extends HttpServlet { private static final long serialVersionUID = -4798851845756886622L; @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
int start = Integer.parseInt(req.getParameter("start"));
int limit = Integer.parseInt(req.getParameter("limit"));
LogDAO logDAO = new LogDAO();
List<Log> list = logDAO.findAll(start , limit);
int total = logDAO.getTotal();
StringBuilder sb = new StringBuilder();
sb.append("{results: " + total + ", rows:[");
for (Log log : list) {
sb.append("{");
sb.append("ID : " + log.getId());
sb.append(", TIMESTAMP : \'" + log.getTimestamp() + "\'");
sb.append(", MODULE : \'" + log.getModule() + "\'");
sb.append(", FUNCTION : \'" + log.getFunction() + "\'");
sb.append(", METHOD : \'" + log.getMethod() + "\'");
sb.append(", USER_ID : \'" + log.getUserId() + "\'");
sb.append(", USER_NAME : \'" + log.getUserName() + "\'");
sb.append(", LOCAL_IP : \'" + log.getLocalIp() + "\'");
sb.append(", REMOTE_IP : \'" + log.getRemoteIp() + "\'");
sb.append(", TYPE : " + log.getType());
sb.append(", FILE_NAME : \'" + log.getFileName() + "\'");
sb.append(", FILE_SIZE : " + log.getFileSize());
sb.append(", PARAMS : \'" + log.getParams() + "\'");
sb.append(", SUCCESS : " + log.getSuccess());
sb.append(", ERROR : \'" + log.getError() + "\'");
sb.append("},");
} String json = sb.substring(0, sb.length() - 1); json += "]}";
resp.setContentType("text/html");
resp.setCharacterEncoding("UTF-8");
PrintWriter out = resp.getWriter();
out.println(json);
out.close();
} }
grid.js
Ext.onReady(function(){
var itemsPerPage = 10; var store = Ext.create('Ext.data.Store',{
autoLoad: {start: 0, limit: itemsPerPage},
fields: ['ID','TIMESTAMP','MODULE','FUNCTION','METHOD','USER_ID','USER_NAME'
,'LOCAL_IP','REMOTE_IP','TYPE','FILE_NAME','FILE_SIZE','PARAMS','SUCCESS','ERROR'],//定义字段
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: 'log.do',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'results'
}
}
});
//创建Grid表格组件
Ext.create('Ext.grid.Panel',{
title : 'Grid表格示例',
renderTo: Ext.getBody(),
width:1300,
height:330,
frame:true,
store: store, columns: [//配置表格列
{header: "ID", width: 80, dataIndex: 'ID', sortable: true},
{header: "TIMESTAMP", width: 80, dataIndex: 'TIMESTAMP', sortable: true},
{header: "MODULE", width: 80, dataIndex: 'MODULE', sortable: true},
{header: "FUNCTION", width: 80, dataIndex: 'FUNCTION', sortable: true},
{header: "METHOD", width: 80, dataIndex: 'METHOD', sortable: true},
{header: "USER_ID", width: 80, dataIndex: 'USER_ID', sortable: true},
{header: "USER_NAME", width: 80, dataIndex: 'USER_NAME', sortable: true},
{header: "LOCAL_IP", width: 80, dataIndex: 'LOCAL_IP', sortable: true},
{header: "REMOTE_IP", width: 80, dataIndex: 'REMOTE_IP', sortable: true},
{header: "TYPE", width: 80, dataIndex: 'TYPE', sortable: true},
{header: "FILE_NAME", width: 80, dataIndex: 'FILE_NAME', sortable: true},
{header: "FILE_SIZE", width: 80, dataIndex: 'FILE_SIZE', sortable: true},
{header: "PARAMS", width: 80, dataIndex: 'PARAMS', sortable: true},
{header: "SUCCESS", width: 80, dataIndex: 'SUCCESS', sortable: true},
{header: "ERROR", width: 80, dataIndex: 'ERROR', sortable: true}
],
bbar:[{
xtype: 'pagingtoolbar',
store: store,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "当前查询条件无数据,请重新查询"
}]
});
});
index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyTestWeb</title>
<link type="text/css" rel="stylesheet" href="resource/common/extjs/resources/css/ext-all-neptune.css" />
</head>
<body >
<script type="text/javascript" src="resource/common/extjs/ext-all.js"></script>
<script type="text/javascript" src="resource/common/extjs/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="resource/common/extjs/packages/ext-theme-neptune/build/ext-theme-neptune.js"></script>
<script type="text/javascript" src="resource/grid/grid.js"></script>
<%--<div >
</div>
--%></body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet>
<servlet-name>Log</servlet-name>
<servlet-class>
com.example.servlet.LogServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Log</servlet-name>
<url-pattern>/log.do</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
oracle+servlet+extjs4 分页表格布局示例代码的更多相关文章
- devexpress layoutcontrol 自动生成布局示例代码
foreach (var row in lst.Select(x => x.crow).Distinct()) { LayoutControlItem layout_preitem = null ...
- Android课程---表格布局TableLayout
特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...
- 【译】用Fragment创建动态的界面布局(附Android示例代码)
原文链接:Building a Dynamic UI with Fragments 为了在Android上创建一个动态和多视图的用户界面,你需要封装UI控件和模块化Activity的行为,以便于你能够 ...
- 一个非常标准的Java连接Oracle数据库的示例代码
最基本的Oracle数据库连接代码(只针对Oracle11g): 1.右键项目->构建路径->配置构建路径,选择第三项“库”,然后点击“添加外部Jar”,选择“D:\Oracle\app\ ...
- Java连接Oracle数据库的示例代码
最基本的Oracle数据库连接代码(只针对Oracle11g): 1.右键项目->构建路径 ->配置构建路径,选择第三项“库”,然后点击“添加外部Jar”,选择 “D:\Oracle\ap ...
- 基于jQuery表格增加删除代码示例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 介绍一款jquery ui组件gijgo(含tree树状结构、grid表格),特点:简易、文档全清晰易懂、示例代码
http://gijgo.com gijgo组件 特点:简易.文档全-虽然是英文的但是清晰易懂可读性强.含示例代码(后端直接用原生.Net C# MVC的哦!非常合.Net开发胃口),网站网速快, ...
- 基于DIV+ul+li实现的表格(多示例)
一个无序列表biaoge,前四个列表项我们赋予了类biaotou.因为这四个项是表格头部,应该与表格数据有所区别.所以单独赋予了类,可以方便控制.下面我们开始CSS代码的编写:由 www.169it. ...
- Extjs4中的布局
布局用于定义容器如何组织内部子元素和控制子元素的大小.在一个应用程序中,作为定义容器的组织形式,布局是一个十分重要的组件.是显示单个子元素?还是垂直或水平显示多个子元素?这些均由布局来定义.并且布局将 ...
随机推荐
- How to Install The Alpha Control Packages.
Uninstalling previous version of the package If you have a previous version of the package already i ...
- iOS Waxpatch项目(动态更新)
我的iOS Waxpatch项目地址https://github.com/piaojin/iOS-WaxPatch
- iOS之九宫格图片
照片 现在人们的生活越来越丰富了,很多美好的瞬间都定格在一张张色彩绚丽的照片上,或许把照片珍藏在相册里,或许通过社交软件分享给亲朋好友.那社交软件上的照片是以什么形式展现的呢?那么接下来就要说到九宫格 ...
- 错误:ORA-28009: connection as SYS should be as SYSDBA or SYSOPER 的解决办法--转载但验证过后可以用
今天,用iSQL*Plus 以sys用户连接数据库的时候报ORA-28009:connection as sys should be as sysdba or sysoper的错误,不知道是怎么回事, ...
- windows自带FTP开启后,浏览器打不开的问题
问题描述:最近需要安装一个FTP服务器,傻瓜式的下一步下一步之后,用IE登录却发现登录不上,总是显示连接中,查找了一下网上别人的回答,发现原来系统的FTP是由主动跟被动的区别的. 问题解决:在IE下, ...
- PCA数据降维
Principal Component Analysis 算法优缺点: 优点:降低数据复杂性,识别最重要的多个特征 缺点:不一定需要,且可能损失有用的信息 适用数据类型:数值型数据 算法思想: 降维的 ...
- c#中文件与二进制流文件的转换
将文件转换成二进制方法: /// <summary> /// 将文件转换成二进制 /// </summary> /// <param name=&quo ...
- C++中随机数和不重复的随机数
随机数 int rand (); rand函数返回一个0-32767之间的一个伪随机整数,32767可以由宏RAND_MAX表示,该函数需要头文件<stdlib.h>. 常用的是如何生成一 ...
- 关于在程序中 文件新生成 在用os.system()程序对新生成的文件处理 举个栗子 如下:
print 'save to ',savedir+os.sep+d["FILE_NAME"] ff = open(savedir+os.sep+d[& ...
- BZOJ 2844 albus就是要第一个出场 ——高斯消元 线性基
[题目分析] 高斯消元求线性基. 题目本身不难,但是两种维护线性基的方法引起了我的思考. void gauss(){ k=n; F(i,1,n){ F(j,i+1,n) if (a[j]>a[i ...