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 分页表格布局示例代码的更多相关文章

  1. devexpress layoutcontrol 自动生成布局示例代码

    foreach (var row in lst.Select(x => x.crow).Distinct()) { LayoutControlItem layout_preitem = null ...

  2. Android课程---表格布局TableLayout

    特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...

  3. 【译】用Fragment创建动态的界面布局(附Android示例代码)

    原文链接:Building a Dynamic UI with Fragments 为了在Android上创建一个动态和多视图的用户界面,你需要封装UI控件和模块化Activity的行为,以便于你能够 ...

  4. 一个非常标准的Java连接Oracle数据库的示例代码

    最基本的Oracle数据库连接代码(只针对Oracle11g): 1.右键项目->构建路径->配置构建路径,选择第三项“库”,然后点击“添加外部Jar”,选择“D:\Oracle\app\ ...

  5. Java连接Oracle数据库的示例代码

    最基本的Oracle数据库连接代码(只针对Oracle11g): 1.右键项目->构建路径 ->配置构建路径,选择第三项“库”,然后点击“添加外部Jar”,选择 “D:\Oracle\ap ...

  6. 基于jQuery表格增加删除代码示例

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 介绍一款jquery ui组件gijgo(含tree树状结构、grid表格),特点:简易、文档全清晰易懂、示例代码

    http://gijgo.com   gijgo组件 特点:简易.文档全-虽然是英文的但是清晰易懂可读性强.含示例代码(后端直接用原生.Net C# MVC的哦!非常合.Net开发胃口),网站网速快, ...

  8. 基于DIV+ul+li实现的表格(多示例)

    一个无序列表biaoge,前四个列表项我们赋予了类biaotou.因为这四个项是表格头部,应该与表格数据有所区别.所以单独赋予了类,可以方便控制.下面我们开始CSS代码的编写:由 www.169it. ...

  9. Extjs4中的布局

    布局用于定义容器如何组织内部子元素和控制子元素的大小.在一个应用程序中,作为定义容器的组织形式,布局是一个十分重要的组件.是显示单个子元素?还是垂直或水平显示多个子元素?这些均由布局来定义.并且布局将 ...

随机推荐

  1. href使用 javascript:;与javascript:void(0)防跳到顶部

    有时候我们在编写js过程中,需要触发事件而不需要返回值,那么就可能需要这样的写法   href=”#”,包含了一个位置信息.默认的锚是#top,也就是网页的上端,当连续快速点击此链接时会导致浏览器巨慢 ...

  2. request getParameter getAttribute

    在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:8888/Test/index.jsp?test=123 在index.jsp中尝试使用EL表达式取出,代码如 ...

  3. Redis的缓存策略和主键失效机制

    作为缓存系统都要定期清理无效数据,就需要一个主键失效和淘汰策略. >>EXPIRE主键失效机制 在Redis当中,有生存期的key被称为volatile,在创建缓存时,要为给定的key设置 ...

  4. 【Java EE 学习 35 下】【struts2】【struts2文件上传】【struts2自定义拦截器】【struts2手动验证】

    一.struts2文件上传 1.上传文件的时候要求必须使得表单的enctype属性设置为multipart/form-data,把它的method属性设置为post 2.上传单个文件的时候需要在Act ...

  5. MyBatis学习(四)MyBatis和Spring整合

    MyBatis和Spring整合 思路 1.让spring管理SqlSessionFactory 2.让spring管理mapper对象和dao. 使用spring和mybatis整合开发mapper ...

  6. Oracle监听的静态注册和动态注册

    静态注册:通过解析listene.ora文件 动态注册:由PMON进程动态注册至监听中 在没有listener.ora配置文件的情况下,如果启动监听,则监听为动态注册.用图形化netca创建的监听,默 ...

  7. <转>SQL Server返回最后一个标识值的三个函数:IDENT_CURRENT、@@IDENTITY、SCOPE_IDENTITY

    MSDN对官方解释:这三个函数都返回最后生成的标识值. 但是,上述每个函数中定义的“最后”的作用域和会话有所不同. 1.IDENT_CURRENT 返回为某个会话和当前作用域中的指定表生成的最新标识值 ...

  8. POJ 1743 Musical Theme 二分+后缀数组

    Musical Theme   Description A musical melody is represented as a sequence of N (1<=N<=20000)no ...

  9. Zookeeper分布式集群搭建

    实验条件:3台安装linux的机子,配置好Java环境. 步骤1:下载并分别解包到每台机子的/home/iHge2k目录下,附上下载地址:http://mirrors.cnnic.cn/apache/ ...

  10. CSS3动画效果-7.13

    例如: <body> <div class="div1"></div> </body> CSS: @keyframes myfirs ...