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. hadoop 笔记

    我们常说的分布式系统,其实就是分布式软件系统,支持分布式处理的软件系统.他是在通信网络互联的多处理机体系结构上执行任务.   hadoop是分布式软件系统中文件系统层的软件,他实现了分布式文件系统和部 ...

  2. AT常见问题

    https://m.douban.com/note/247040789/?from=author

  3. FluentData(微型ORM)

    using FluentData; using System; using System.Collections.Generic; using System.Linq; using System.Te ...

  4. 收藏的几个经典Flash

    本人收藏了几个有意思的Flash,在此与大家分享下 1.黄金矿工中文版.swf 2.中国象棋.swf 3.运动的老鼠.swf 4.时钟.swf 5. 2048.swf 6.小猫逃跑.swf

  5. Theano在windows下的安装及GPU加速

    安装环境:wondows 64bit Teano安装测试 1. Anaconda 安装 Anaconda是一个科学计算环境,自带的包管理器conda很强大.之所以选择它是因为它内置了python,以及 ...

  6. [转载]使用PyQt来编写第一个Python GUI程序

    转载自:http://python.jobbole.com/81276/ 英文版出处:http://pythonforengineers.com/your-first-gui-app-with-pyt ...

  7. div滚动底部加载li,window滚动底部加载li

    DIV固定高度滚动条滚动最底部,加载新的li <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...

  8. Appirater -- app中提示用户为app评价的提示框

    Appirater是一段你可以嵌入自己工程中的代码,在用户使用应用一段时间后会自动弹出提示用户进行评分. 使用Appirater方面,你可以简单把源代码嵌入你的app工程中,并把以下代码添加至它的委托 ...

  9. Scrum项目8.0

    目标:我们开始做每个需要细致的界面,比方说登陆,注册,游戏界面,难度选择 内容:登陆界面:登陆名,登陆密码,登陆按钮,以及优美的底图. 注册页面:名称,密码,登陆按钮,以及优美的底图. 游戏界面:难度 ...

  10. Mac iTerm 很好用的终端

    配合Go2Shell使用,效果更佳!我建议你去商店下载它! 先去官网下载软件, 然后可以看看这一篇简明教程. 这里,还有一点点干货也一起带走吧! open -a Go2Shell --args con ...