这篇博客是在实习期间在公司写的,公司让用miniui来作为软件开发的前端框架,在学习了一段时间后做一个总结,算是给自己实习的一份小礼物吧。

首先,先来看看效果图,虽然比不上工作经验丰富的同事,但也可借鉴一番!

我设计显示了三个界面,这是第一个界面,只是简单的数据的增删改查界面,是我用来做后面两个界面的练手界面。

这是第二个界面,用来进行新增信息的界面,新增的信息保存后会在第三个界面显示。

这是第三个界面,用来显示表格数据的,同时也可进行修改和删除操作!

上面三张图就是这次要做的内容,希望对miniui新手有帮助!

一:准备篇

1:安装JDK、安装MyEclipse、安装Sqlserver(公司用的数据库)、tomcat7.0。
以上这些都是基础的内容,这里就不赘述了,不知道的度娘吧!
2:建数据库+建表。建数据库就不说了,可自行建立和取名字,给出两张表的数据字典,可以根据数据字典来建表。


这是第一张表,表的名字可以用数据字典上的名字。

这是第二张表,名字也按照数据字典来命名。
3:测试数据。在测试数据库中数据是否可以被MyEclipse获取到时,先在建好的表中添加适量的数据,数据的添加注意字段的类型。
3.1:JDBC连接。写一个TestDB.java类,并写jdbc连接代码。
3.2:在MyEclipse中创建数据库对象并连接。

点击Finish后右键数据库-->Open就可打开你创建的数据库
二:界面篇
1:框架界面,outlookmenu.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><base href="<%=basePath%>"><title>My JSP 'outlookmenu.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--     <link rel="stylesheet" type="text/css" href="styles.css"> --><script type="text/javascript" src="${pageContext.request.contextPath }/scripts/boot.js"></script><style type="text/css">body{margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;}.header{background:url(${pageContext.request.contextPath}/demo/back_color.gif) repeat-x 0 -1px}.Node{background:url(Notes_Large.png)no-repeat;width:32px;height:32px;}.Reports{background:url(Reports_Large.png)no-repeat;width:32px;height:32px;}</style></head><body><div id="layout1" class="mini-layout"  style="width:100%;height:100%"><div class="header" region="north" height="70px" showSplit="false" showHeader="false"><table align="left"><tr><td rowspan="3"><h1 style="margin:0;padding:15px;cursor:default;font-family:'Trebuchet MS',Arial,sans-serif;width:300px">微讯通管理系统</h1></td></tr></table><table align="right"><tr align="right"><td ><label name="username" class="mini-text">用户名:</label></td><td><input  name="username" id="ls_username" autocomplete="off" class="mini-textbox"  /></td><td class="fastlg_l"><input name="cookietime" id="ls_cookietime" class="mini-checkbox" align="center" />自动登录</label></td><td> <a  href="showWindow()">找回密码</a></td></tr><tr><td><label name="password" class="mini-text">密   码:</label></td><td><input  name="password" id="ls_password" class="mini-password"   /></td><td ><a class="mini-button" >登  录</button></td><td> <a href="http://www.miniui.com/bbs/member.php?mod=register" >立即注册</a></td></tr></table></div><div title="south" region="south" showSplit="false" showHeader="false" height="30"><div style="line-height:28px;text-align:center;cursor:default">Copyright © 深圳微讯通软件有限公司版权所有</div></div><div region="west" width="180" style="background:#C2D3F0" maxWidth="250" minWidth="100" showHeader="false"><div id="leftTree" class="mini-outlookmenu" url="${pageContext.request.contextPath }/demo/data/outlookmenu.txt" onitemselect="onItemSelect"idField="id" parentField="pid" textField="text" borderStyle="border:0"></div></div><div region="center" title="center" bodyStyle="overflow:hidden"><iframe id="mainframe" frameborder="0" name="main" style="width:100%;height:100%" border="0"></iframe></div></div><script type="text/javascript">mini.parse();//iframe srcvar iframe = document.getElementById("mainframe");iframe.src = "${pageContext.request.contextPath}/demo/datagrid/Tab.jsp";function onItemSelect(){var item = e.item;iframe.src = item.url;}</script></body>
</html>

outlookmenu.txt-->json文件

[{ id: "user", text: "用户管理", iconCls: "icon-add"},{ id: "addUser", pid: "user", text: "增加用户", iconCls: "icon-add", url: "../datagrid/celledit.html" },{ id: "editUser", pid: "user", text: "修改用户", iconCls: "icon-edit", url: "../datagrid/rowedit.html" },{ id: "removeUser", pid: "user", text: "删除用户", iconCls: "icon-remove", url: "../datagrid/datagrid.html" },{ id: "right", text: "权限管理"},{ id: "addRight", pid: "right", text: "查询权限", iconCls: "icon-Note", url: "${pageContext.request.contextPath}/demo/tree/detailgrid.html", iconPosition: "top" },{ id: "editRight", pid: "right", text: "操作权限", iconCls: "icon-Reports", url: "../buttonedit/selectGrid.html", iconPosition: "top" }
]

2:数据显示界面,Tab.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";String masterId = request.getParameter("masterId");
%><html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<base href="<%=basePath%>"><title>Tab 表单编辑</title><meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><!--  <link rel="stylesheet" type="text/css" href="styles.css"> --><script src="${pageContext.request.contextPath}/scripts/boot.js" type="text/javascript"></script></head>
<body><div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;background:#C2D3F0" bodyStyle="padding:0;border:0"><div title="用户管理" iconCls="icon-user"><style type="text/css">
body {  margin: 0;padding: 0;border: 0;width: 100%;height: 100%;overflow: hidden;
}
</style><div style="width:100%"><div class="mini-toolbar" style="border-bottom:0;padding:0px;"><table style="width:100%;"><tr><td style="width:100%;"><a class="mini-button" iconcls="icon-add" οnclick="addRow1()" plain="true">增加</a> <a class="mini-button" iconcls="icon-remove" οnclick="removeRow1()" plain="true">删除</a><span class="separator"></span> <a class="mini-button" iconcls="icon-save" οnclick="saveData1()" plain="true">保存</a></td><td style="white-space:nowrap;">年月 <input id="birthday" showNullItem="true" class="mini-monthpicker" style="width:120px;" showClearButton="true" onvaluechanged="search1()" /> 国家 <inputid="countrys" showNullItem="true" class="mini-combobox" style="width:80px;" url="" onvaluechanged="search1()" /> <input id="key" class="mini-textbox" emptytext="请输入姓名"style="width:150px;" onenter="search1()" /> <a class="mini-button" οnclick="search1()">查询</a></td></tr></table></div></div><div class="mini-fit"><div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" url="${pageContext.request.contextPath}/demo/data/AjaxService.jsp?method=SearchEmployeesByMultiSort" idfield="id"allowresize="true" pagesize="20" allowcelledit="true" allowcellselect="true" multiselect="true" editnextonenterkey="true" editnextrowcell="true"><div property="columns"><div type="indexcolumn"></div><div type="checkcolumn"></div><div field="name" width="100" allowsort="true">姓名 <input property="editor" class="mini-textbox" minwidth="200" /></div><div name="LoginName" field="loginname" headeralign="center" allowsort="true" width="150">员工帐号 <input property="editor" class="mini-textbox" minwidth="200" /></div><div field="age" width="100" allowsort="true">年龄 <input property="editor" class="mini-spinner" minvalue="0" maxvalue="200" value="25" /></div><div name="birthday" field="birthday" width="100" allowsort="true" dateformat="yyyy-MM-dd">出生日期 <input property="editor" class="mini-datepicker" /></div><div field="remarks" width="120" headeralign="center" allowsort="true">备注 <input property="editor" class="mini-textarea" style="width:200px;" minwidth="200" minheight="50" /></div><!--ComboBox:本地数据--><div type="comboboxcolumn" autoshowpopup="true" name="gender" field="gender" width="100" allowsort="true" align="center" headeralign="center">性别 <input property="editor" class="mini-combobox" data="Genders" /></div><!--ComboBox:远程数据--><div type="comboboxcolumn" field="country" width="100" headeralign="center">国家 <input property="editor" class="mini-combobox" url="${pageContext.request.contextPath}/demo/data/countrys.txt" /></div><div type="checkboxcolumn" field="married" truevalue="1" falsevalue="0" width="60" headeralign="center">婚否</div></div></div></div></div><div title="新增管理" iconCls="icon-add"><style type="text/css">html,body {margin: 0;padding: 0;border: 0;width: 100%;height: 100%;overflow: hidden;}</style><div style="mini-fit" id="form1"><div class="mini-toolbar" style="border-bottom:0;padding:0px;"><table><td style="width:100%;"><a class="mini-button" iconcls="icon-save" οnclick="saveData2()" plain="true">保存</a> <a class="mini-button" iconcls="icon-remove" οnclick="removeRow2()" plain="true">关闭</a></td></table></div><div style="width:100%;height:100%;"><table style="width: 800px"><tr style="width: 800px"><td><label style="float:right;">流水号:</label></td><td style="width: 220px"><input type="hidden" id="JyId" name="Jyid" style="width: 220px" class="mini-textbox" /> </td><td><label style="float:right;">控制人:</label></td><td><input id="control" name="control" textName="control" class="mini-buttonedit" required="true" /></td><td><label style="float:right;">归档:</label></td><td><input id="archive" name="archive" textName="archive" class="mini-buttonedit" class="mini-textbox" /></td></tr><tr><td><label style="float:right;">版本号:</label></td><td><input id="version" style="width:220px" textName="version" name="version" class="mini-buttonedit" /></td><td><label style="float:right;">编号:</label></td><td><input id="number" name="number" class="mini-textbox" /></td><td><label style="float:right;">年度:</label></td><td><input name="year" class="mini-combobox" showNullItem="true" emptytext="请选择年份" textField="text" valueField="id" data="yearData" /></td></tr><tr><td><label style="float:right;">生效日:</label></td><td colspan="5"><input id="attachDate" style="width: 220px" name="attachDate" class="mini-datepicker" /></td></tr><tr style="height: 40px"><td style="width:60px;" align="right">检验项目:</td><td colspan="2"><input id="testProject" name="testProject" textName="testProject" class="mini-buttonedit" height="50" style="width: 100%" /></td><td style="width:60px;" align="right">分析仪器:</td><td colspan="2"><input id="analyze" name="analyze" textName="analyze" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr><tr style="height: 40px"><td><label style="float:right;">新批号:</label></td><td colspan="2"><input id="newBeach" name="newBeach" class="mini-textbox" style="width: 100%" /></td><td><label style="float:right;">旧批号:</label></td><td colspan="2"><input id="oldBeach" name="oldBeach" class="mini-textbox" style="width: 100%" /></td></tr><tr style="height: 50px"><td style="width:60px;" align="right">判断标准:</td><td colspan="5"><input id="judge" name="judge" textName="judge" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr><tr style="height: 50px"><td style="width:60px;" align="right">对比方案:</td><td colspan="5"><input id="comparison" name="comparison" textName="comparison" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr></table></div></div><div class="mini-fit"><div class="mini-toolbar" style="border-bottom:0;padding:0px;"><table style="width:100%;"><tr><td style="width:100%;"><a class="mini-button" iconcls="icon-add" οnclick="addRow2()" plain="true">新增</a></td></tr></table></div><div id="datagrid2" class="mini-datagrid" style="width:100%;height:350px;" editnextonenterkey="true" editnextrowcell="true" showPager="false" allowcellselect="true" multiselect="true"allowresize="true" fitColumns="false" allowcelledit="true"><div property="columns"><div type="indexcolumn">序号</div><div type="checkcolumn"></div><div name="Sample" field="sample" width="130px" allowsort="true" headeralign="center"><b>样本标识或条码号</b> <input property="editor" class="mini-textbox" /></div><div field="oldx" vtype="required;float" headeralign="center" width="100px"><b>旧(Y)(%)</b> <input property="editor" class="mini-textbox" /></div><div field="newx" vtype="required;float" headeralign="center" width="100px"><b>新(X)(%)</b> <input property="editor" class="mini-textbox" /></div><div field="absolute" width="180px" type="required;float" headeralign="center"><b>X-Y/Y*100%绝对值或符合性</b> <input property="editor" class="mini-textbox" /></div><div field="scope" headeralign="center" width="180px"><b>可接受范围(1/2TEa或符合率)</b> <input property="editor" class="mini-textbox" /></div></div></div><div class="mini-fit" id="form1"><table style="width: 800px"><tr style="width: 800px"><td align="left" colspan="2" style="width: 120px">结论</td><td style="width: 115px"><div id="cbl1" class="mini-checkboxlist" repeatItems="1" repeatLayout="table" textField="text" valueField="id" multiSelect="false" data="das"></div></td><td colspan="3" style="width:360px" valign="bottom">(描述:<input id="Conclusion" name="Conclusion" class="mini-text" style="border:0px;width: 90%" />)</td></tr><tr style="width: 800px"><td align="left">分析人:</td><td style="width: 100px"><input class="mini-buttonedit" name="analysisPeople" height="50" style="width: 100%" /></td><td>签名:</td><td><input class="mini-buttonedit" name="Remark1" height="50" style="width: 100%" /></td><td>分析日期:</td><td><input class="mini-datepicker" name="analysisTime" height="50" style="width: 100%" format="yyyy-MM-dd" /></td></tr><tr style="width: 800px"><td align="left">审核者:</td><td style="width: 100px"><input class="mini-buttonedit" name="audit" height="50" style="width: 100%" /></td><td>组长:</td><td><input class="mini-buttonedit" name="Remark1" height="50" style="width: 100%" /></td><td>审核日期:</td><td><input class="mini-datepicker" name="auditTime" height="50" style="width: 100%" format="yyyy-MM-dd" /></td></tr></table></div></div></div><div title="查询管理" showCloseButton="true" iconCls="icon-search"><style type="text/css">.New_Button,.Edit_Button,.Delete_Button,.Update_Button,.Cancel_Button {font-size: 11px;color: #1B3F91;font-family: Verdana;margin-right: 5px;}</style><div class="mini-fit"><div class="mini-toolbar" style="border-bottom:0;padding:0px;"><table style="width:100%;"><tr><td style="white-space:nowrap;">年度 <input id="year2" showNullItem="true" align="center" data="yearData" width="100px"class="mini-combobox"  onvaluechanged="search3()" /> 版本号 <inputid="version" showNullItem="true" width="80px" class="mini-combobox" data="varsionData" onvaluechanged="search3()" /> <input id="key2" class="mini-textbox" emptytext="请输入控制人" style="width:150px;"onenter="search3()" /> <a class="mini-button" οnclick="search3()">查询</a></td><td style="width:100%;"><a class="mini-button" iconcls="icon-search" οnclick="search3()" plain="true">刷新</a></td></tr></table></div><div id="datagrid3" class="mini-datagrid" style="width:100%;height:420px;" editnextonenterkey="true" editnextrowcell="true" showPager="true" allowcellselect="true" multiselect="true"allowresize="true" pagesize="10" fitColumns="false"  onselectionchanged="onSelectionChanged"   selectOnLoad="true" allowcelledit="true" url="${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=SearchEmployeesByMultiSort"><div property="columns"><div  field="JyId" width="120"  visible="true" >  ID                  </div><div name="action" width="120" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;"><b>操作</b></div><div name="Number" field="Number" width="130px" allowsort="true" headeralign="center"><b>编号</b> <input class="mini-textbox" /></div><div field="Version" vtype="required;float" headeralign="center" width="100px"><b>版本号</b> <input class="mini-textbox" /></div><div field="Archive" vtype="required;float" headeralign="center" width="100px"><b>归档</b> <input class="mini-textbox" /></div><div field="Control" width="180px" type="required;float" headeralign="center"><b>控制人</b> <input class="mini-textbox" /></div><div field="Year" headeralign="center" width="180px"><b>年度</b> <input class="mini-combobox" /></div><div name="AttachDate" field="AttachDate" width="130px" allowsort="true" headeralign="center"><b>生效日</b> <input class="mini-datepicker" /></div><div field="TestProject" vtype="required;float" headeralign="center" width="100px"><b>检验项目</b> <input class="mini-textbox" /></div><div field="Analyze" vtype="required;float" headeralign="center" width="100px"><b>分析仪器</b> <input class="mini-textbox" /></div><div field="NewBeach" width="180px" type="required;float" headeralign="center"><b>新批号</b> <input class="mini-textbox" /></div><div field="OldBeach" headeralign="center" width="180px"><b>旧批号</b> <input class="mini-textbox" /></div><div field="Judge" width="180px" type="required;float" headeralign="center"><b>判断标准</b> <input class="mini-textbox" /></div><div field="Comparison" headeralign="center" width="180px"><b>对比方案</b> <input class="mini-textbox" /></div></div></div><!--                 <div id="editForm1" style="display:none;padding:5px;position:relative;"> -->
<!--                     <input class="mini-hidden" name="JyId" /> -->
<!--                     <table style="width:100%;"> -->
<!--                         <tr> -->
<!--                             <td style="width:80px;" align="right">编号:</td> -->
<!--                             <td style="width:150px;" ><input name="Number" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                             <td style="width:80px;" align="right">版本号:</td> -->
<!--                             <td style="width:150px;" ><input name="Version" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                             <td style="width:80px;" align="right">归档:</td> -->
<!--                             <td style="width:150px;" ><input name="Archive" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                             <td style="width:80px;" align="right">控制人:</td> -->
<!--                             <td style="width:150px;" ><input name="Control" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                         </tr> -->
<!--                         <tr> -->
<!--                             <td align="right">年度:</td> -->
<!--                             <td><input name="Year" showNullItem="true" class="mini-combobox"  data="yearData"/> -->
<!--                             </td> -->
<!--                             <td align="right">检验项目:</td> -->
<!--                             <td><input name="TestProject" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                             <td align="right">新批号:</td> -->
<!--                             <td><input name="NewBeach" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                             <td  align="right">旧批号:</td> -->
<!--                             <td ><input name="OldBeach" class="mini-textbox" /> -->
<!--                             </td> -->
<!--                         </tr> -->
<!--                         <tr> -->
<!--                             <td style="text-align:center;padding-top:5px;padding-right:20px;" colspan="6"><a class="Update_Button" href="javascript:updateRow();">确   认</a> <a class="Cancel_Button" -->
<!--                                 href="javascript:cancelRow();">取  消</a></td> -->
<!--                         </tr> -->
<!--                     </table> -->
<!--                 </div> --></div><div class="mini-fit"><div id="datagrid4" class="mini-datagrid" style="width:100%;height:380px;" editnextonenterkey="true" editnextrowcell="true" showPager="false" allowcellselect="true" multiselect="true"allowresize="true"  idField="id" fitColumns="false" allowcelledit="true" url="${pageContext.request.contextPath}/demo/data/AjaxService3.jsp?method=GetDepartmentEmployees"><div property="columns"><div type="indexcolumn">序号</div><div type="checkcolumn"></div><div name="Sample" field="Sample" width="130px" allowsort="true" headeralign="center"><b>样本标识或条码号</b> <input  class="mini-textbox" /></div><div field="Oldx" vtype="required;float" headeralign="center" width="100px"><b>旧(Y)(%)</b> <input class="mini-textbox" /></div><div field="Newx" vtype="required;float" headeralign="center" width="100px"><b>新(X)(%)</b> <input  class="mini-textbox" /></div><div field="Absolute" width="180px" type="required;float" headeralign="center"><b>X-Y/Y*100%绝对值或符合性</b> <input  class="mini-textbox" /></div><div field="Scope" headeralign="center" width="180px"><b>可接受范围(1/2TEa或符合率)</b> <input  class="mini-textbox" /></div></div></div></div></div></div><script type="text/javascript">var Genders = [ {id : 1,text : '男'}, {id : 2,text : '女'} ];var das = [ {id : 1,text : '可接受'}, {id : 2,text : '不可接受'    } ];var yearData = [ {id : 1,text : '2017'}, {id : 2,text : '2016'} , {id : 3,text : '2015'}, {id : 4,text : '2014'}, {id : 5,text : '2013'}];var varsionData = [ {id : 1,text : 'Ver1.00'}, {id : 2,text : 'Ver2.00'} , {id : 3,text : 'Ver3.00'}, {id : 4,text : 'Ver4.00'}];mini.parse();var grid1 = mini.get("datagrid1");var grid2 = mini.get("datagrid2");var grid3 = mini.get("datagrid3");var grid4 = mini.get("datagrid4");grid1.load();grid2.load();grid3.load();var editForm = document.getElementById("editForm1"); function search1() {var key = mini.get("key").getValue();var aa = mini.get("birthday").getText();var json = {key : key,birthday : aa,countrys : mini.get("countrys").getValue()};grid1.load(json);}function onKeyEnter1(e) {search();}function addRow1() {var newRow = {name : "New Row"};grid1.addRow(newRow, 0);grid1.beginEditCell(newRow, "LoginName");}function removeRow1() {var rows = grid1.getSelected();var age = rows.age;if (age < 4) {$.ajax({url : "${pageContext.request.contextPath}/demo/data/AjaxService.jsp?method=DeletePerSon&id="+ rows.id,success : function(text) {grid1.reload();},error : function() {alert("表单加载错误");form.unmask();}});}}function saveData1() {var data = grid1.getChanges();var json = mini.encode(data);grid1.loading("保存中,请稍后......");$.ajax({url : "${pageContext.request.contextPath}/demo/data/AjaxService.jsp?method=SaveEmployees",data : {data : json},type : "post",success : function(text) {grid1.reload();},error : function(jqXHR, textStatus, errorThrown) {alert(jqXHR.responseText);}});}//查询管理中的表格联动function onSelectionChanged(e) {        var grid3 = e.sender;var record = grid3.getSelected();if (record) {grid4.load({JyId:record.JyId});}}function onActionRenderer(e) {var grid = e.sender;var record = e.record;var uid = record._uid;var rowIndex = e.rowIndex;var s =' <a class="Edit_Button" href="javascript:editRow()" >修改</a>'+ ' <a class="Delete_Button" href="javascript:delRow(\'' + uid + '\')">删除</a>';
//             if (grid.isEditingRow(record)) {
//                 s = '<a class="Update_Button" href="javascript:updateRow(\'' + uid + '\')">确定</a>'
//                     + '<a class="Cancel_Button" href="javascript:cancelRow(\'' + uid + '\')">取消</a>';
//             }return s;}function editRow() {var row = grid3.getSelected();if (row) {mini.open({url:  "${pageContext.request.contextPath}/demo/datagrid/TabEdit.jsp",title: "修改", width: 805, height: 850,onload: function () {var iframe = this.getIFrameEl();var data = { action: "edit",  id: row.JyId};iframe.contentWindow.SetData(data);},ondestroy: function (action) {grid3.reload();}});} else {alert("请选中一条记录");}//             var row = grid3.getRowByUID(row_uid);
//             if (row) {//显示行详细
//                 grid3.hideAllRowDetail();
//                 grid3.showRowDetail(row);// 将editForm元素,加入行详细单元格内
//                 var td = grid3.getRowDetailCellEl(row);
//                 td.appendChild(editForm);
//                 editForm.style.display = "";//表单加载员工信息
//                 var form = new mini.Form("editForm1");
//                 if (grid3.isNewRow(row)) {
//                     form.reset();
//                 } else {
//                     form.loading();
//                     $.ajax({
//                         url: "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=GetEmployee&JyId=" + row.JyId,
//                         success: function (text) {
//                             var o = mini.decode(text);
//                             form.setData(o);
//                             form.unmask();
//                         }
//                     });
//                 }
//                 grid3.doLayout();
//             }}function cancelRow() {grid3.reload();}function delRow() {var rows = grid3.getSelected();$.ajax({url : "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=DeletePerSon&JyId="+ rows.JyId,success : function(text) {if (text == "ok") {grid3.reload();} else {grid3.reload();}},error : function() {alert("表单加载错误");form.unmask();}});}function updateRow() {var data = grid3.getChanges();var json = mini.encode(data);grid3.loading("保存中,请稍后......");$.ajax({url: "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=SaveEmployees",data: { data: json },type: "post",success: function (text) {grid3.reload();},error: function (jqXHR, textStatus, errorThrown) {alert(jqXHR.responseText);}});//对样本表内容进行保存
//          var form = new mini.Form("editForm1");//对项目表内容进行保存
//          var data = form.getChanges(); //获取表单多个控件的数据
//          var json = mini.encode(data); //序列化成JSON
//          var da = {
//              submitData : json,
//          };
//          $.ajax({
//                      url : "${pageContext.request.contextPath}/demo/data/FormService.jsp?method=SaveData",
//                      type : "post",
//                      data : da,
//                      success : function(text) {
//                          grid3.reload();
//                      }
//                  });//             var form = new mini.Form("editForm1");//             var o = form.getData();//             grid3.loading("保存中,请稍后......");
//             var json = mini.encode([o]);//             $.ajax({
//                 url: "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=SaveEmployees",
//                 data: { data: json },
//                 success: function (text) {
//                     grid3.reload();
//                 },
//                 error: function (jqXHR, textStatus, errorThrown) {
//                     alert(jqXHR.responseText);
//                 }
//             });}function addRow2() {var newRow = {name : "New Row"};grid2.addRow(newRow, 0);grid2.beginEditCell(newRow, "Sample");}function removeRow2() {var rows = grid2.getSelected();$.ajax({url : "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=DeletePerSon&JyId="+ rows.JyId,success : function(text) {if (text == "ok") {search();} else {search();}},error : function() {alert("表单加载错误");form.unmask();}});}function saveData2() {//校验  form1.validate();if (form1.isValid() == false)return;//对样本表内容进行保存var datamx = grid2.getData();var jsonmx = mini.encode(datamx);//对项目表内容进行保存 var data = form1.getData(); //获取表单多个控件的数据var json = mini.encode(data); //序列化成JSON var da = {submitData : json,submitDataMx : jsonmx};$.ajax({url : "${pageContext.request.contextPath}/demo/data/FormService.jsp?method=SaveData",type : "post",data : da,success : function(text) {alert(text);}});}function search3() {var key2 = mini.get("key2").getValue();var year2 = mini.get("year2").getText();var version = mini.get("version").getValue();var json = {key : key2,    year:year2,version:version      };grid3.load(json);}grid1.on("celleditenter", function(e) {var index = grid1.indexOf(e.record);if (index == grid1.getData().length - 1) {var row = {};grid1.addRow(row);}});grid1.on("beforeload", function(e) {if (grid1.getChanges().length > 0) {if (confirm("有增删改的数据未保存,是否取消本次操作?")) {e.cancel = true;}}});</script>
</body>
</html>

3.弹出框界面,在第三个界面点击修改后弹出,TabEdit.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";String masterId = request.getParameter("masterId");
%>
<html>
<head>
<base href="<%=basePath%>"><title></title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page">
<!--     <link rel="stylesheet" type="text/css" href="styles.css"> --><script src="${pageContext.request.contextPath}/scripts/boot.js"   type="text/javascript"></script>
</head>
<body><style type="text/css">html,body {margin: 0;padding: 0;border: 0;width: 100%;height: 100%;overflow: hidden;}</style><div style="mini-fit" id="form1"><div class="mini-toolbar" style="border-bottom:0;padding:0px;"><table><td style="width:100%;"><a class="mini-button" iconcls="icon-save" οnclick="saveData2()" plain="true">保存</a> <a class="mini-button" iconcls="icon-remove" οnclick="removeRow2()" plain="true">关闭</a></td></table></div><div style="width:100%;height:100%;"><table style="width: 800px"><tr style="width: 800px"><td><label style="float:right;">流水号:</label></td><td style="width: 220px"><input type="hidden" id="JyId" name="JyId" style="width: 220px" class="mini-textbox" /> </td><td><label style="float:right;">控制人:</label></td><td><input id="Control" name="Control" textName="Control" class="mini-buttonedit" required="true" /></td><td><label style="float:right;">归档:</label></td><td><input id="Archive" name="Archive" textName="Archive" class="mini-buttonedit" class="mini-textbox" /></td></tr><tr><td><label style="float:right;">版本号:</label></td><td><input id="Version" style="width:220px" textName="Version" name="Version" class="mini-buttonedit" /></td><td><label style="float:right;">编号:</label></td><td><input id="Number" name="Number" class="mini-textbox" /></td><td><label style="float:right;">年度:</label></td><td><input input id="Year" name="Year" class="mini-combobox" showNullItem="true" emptytext="请选择年份" textField="text" valueField="id" data="yearData" /></td></tr><tr><td><label style="float:right;">生效日:</label></td><td colspan="5"><input id="AttachDate" style="width: 220px" name="AttachDate" class="mini-datepicker" /></td></tr><tr style="height: 40px"><td style="width:60px;" align="right">检验项目:</td><td colspan="2"><input id="TestProject" name="TestProject" textName="TestProject" class="mini-buttonedit" height="50" style="width: 100%" /></td><td style="width:60px;" align="right">分析仪器:</td><td colspan="2"><input id="Analyze" name="Analyze" textName="Analyze" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr><tr style="height: 40px"><td><label style="float:right;">新批号:</label></td><td colspan="2"><input id="NewBeach" name="NewBeach" class="mini-textbox" style="width: 100%" /></td><td><label style="float:right;">旧批号:</label></td><td colspan="2"><input id="OldBeach" name="OldBeach" class="mini-textbox" style="width: 100%" /></td></tr><tr style="height: 50px"><td style="width:60px;" align="right">判断标准:</td><td colspan="5"><input id="Judge" name="Judge" textName="Judge" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr><tr style="height: 50px"><td style="width:60px;" align="right">对比方案:</td><td colspan="5"><input id="Comparison" name="Comparison" textName="Comparison" class="mini-buttonedit" height="50" style="width: 100%" /></td></tr></table></div></div><div class="mini-fit"><div class="mini-toolbar" style="border-bottom:0;padding:0px;width:800px;""><table style="width:800px;"><tr><td style="width:100%;"><a class="mini-button" iconcls="icon-add" οnclick="addRow2()" plain="true">新增</a></td></tr></table></div><div id="datagrid2" class="mini-datagrid" style="width:800px;height:350px;" editnextonenterkey="true" editnextrowcell="true" showPager="false" allowcellselect="true" multiselect="true"allowresize="true" fitColumns="false" allowcelledit="true"><div property="columns"><div type="indexcolumn">序号</div><div type="checkcolumn"></div><div name="Sample" field="Sample" width="130px" allowsort="true" headeralign="center"><b>样本标识或条码号</b> <input property="editor" class="mini-textbox" /></div><div field="Oldx" vtype="required;float" headeralign="center" width="100px"><b>旧(Y)(%)</b> <input property="editor" class="mini-textbox" /></div><div field="Newx" vtype="required;float" headeralign="center" width="100px"><b>新(X)(%)</b> <input property="editor" class="mini-textbox" /></div><div field="Absolute" width="180px" type="required;float" headeralign="center"><b>X-Y/Y*100%绝对值或符合性</b> <input property="editor" class="mini-textbox" /></div><div field="Scope" headeralign="center" width="180px"><b>可接受范围(1/2TEa或符合率)</b> <input property="editor" class="mini-textbox" /></div></div></div><div class="mini-fit" id="form1"><table style="width: 800px"><tr style="width: 800px"><td align="left" colspan="2" style="width: 120px">结论</td><td style="width: 115px"><div id="cbl1" class="mini-checkboxlist" repeatItems="1" repeatLayout="table" textField="text" valueField="id" multiSelect="false" data="das"></div></td><td colspan="3" style="width:360px" valign="bottom">(描述:<input id="Conclusion" name="Conclusion" class="mini-text" style="border:0px;width: 90%" />)</td></tr><tr style="width: 800px"><td align="left">分析人:</td><td style="width: 100px"><input class="mini-buttonedit" name="AnalysisPeople" height="50" style="width: 100%" /></td><td>签名:</td><td><input class="mini-buttonedit" name="Remark" height="50" style="width: 100%" /></td><td>分析日期:</td><td><input class="mini-datepicker" name="AnalysisTime" height="50" style="width: 100%" format="yyyy-MM-dd" /></td></tr><tr style="width: 800px"><td align="left">审核者:</td><td style="width: 100px"><input class="mini-buttonedit" name="Audit" height="50" style="width: 100%" /></td><td>组长:</td><td><input class="mini-buttonedit" name="Remark1" height="50" style="width: 100%" /></td><td>审核日期:</td><td><input class="mini-datepicker" name="AuditTime" height="50" style="width: 100%" format="yyyy-MM-dd" /></td></tr></table></div></div><script type="text/javascript">var das = [ {id : 1,text : '可接受'}, {id : 2,text : '不可接受'  } ];var yearData = [ {id : 1,text : '2017'}, {id : 2,text : '2016'} , {id : 3,text : '2015'}, {id : 4,text : '2014'}, {id : 5,text : '2013'}];var varsionData = [ {id : 1,text : 'Ver1.00'}, {id : 2,text : 'Ver2.00'} , {id : 3,text : 'Ver3.00'}, {id : 4,text : 'Ver4.00'}];mini.parse();var grid = mini.get("datagrid1");var form = new mini.Form("form1");function SaveData() {var o = form.getData();            form.validate();if (form.isValid() == false) return;var json = mini.encode([o]);$.ajax({url: "../data/AjaxService.jsp?method=SaveEmployees",type: 'post',data: { data: json },cache: false,success: function (text) {CloseWindow("save");},error: function (jqXHR, textStatus, errorThrown) {alert(jqXHR.responseText);CloseWindow();}});}//标准方法接口定义function SetData(data) {if (data.action == "edit") {//跨页面传递的数据对象,克隆后才可以安全使用data = mini.clone(data);$.ajax({url: "${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=GetEmployee&JyId=" + data.JyId,cache: false,success: function (text) {var o = mini.decode(text);form.setData(o);form.setChanged(false);//onDeptChanged();//mini.getbyName("position").setValue(o.position);}});}}function GetData() {var o = form.getData();return o;}function CloseWindow(action) {            if (action == "close" && form.isChanged()) {if (confirm("数据被修改了,是否先保存?")) {return false;}}if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);else window.close();            }function onOk(e) {SaveData();}function onCancel(e) {CloseWindow("cancel");}//function onDeptChanged(e) {var deptCombo = mini.getbyName("JyId");var positionCombo = mini.getbyName("position");var dept_id = deptCombo.getValue();positionCombo.load("${pageContext.request.contextPath}/demo/data/AjaxService2.jsp?method=GetPositionsByDepartmenId&id=" + dept_id);positionCombo.setValue("");}function removeRow() {var rows = grid.getSelected();$.ajax({url : "${pageContext.request.contextPath}/demo/data/AjaxService.jsp?method=DeletePerSon&id="+ rows.id,success : function(text) {if (text == "ok") {search();} else {search();}},error : function() {alert("表单加载错误");form.unmask();}});}function saveData() {//校验   form1.validate();if (form1.isValid() == false)return;//对样本表内容进行保存var datamx = grid.getData();var jsonmx = mini.encode(datamx);//对项目表内容进行保存 var data = form1.getData(); //获取表单多个控件的数据var json = mini.encode(data); //序列化成JSON var da = {submitData : json,submitDataMx : jsonmx};$.ajax({url : "${pageContext.request.contextPath}/demo/data/FormService.jsp?method=SaveData",type : "post",data : da,success : function(text) {alert(text);}});}</script>
</body></html>

4:用到的图片 back_color.gif


5:用到的js文件,可在miniui下载中下载所要的文件,然后只要选择里面的miniui.js、boot.js、jquery-1.6.js三个js文件即可。
三:代码处理篇
1:Service层
1.1:第一个界面Service,AjaxService.jsp
<%@page import="com.sun.xml.internal.bind.v2.runtime.Name"%>
<%@page import="javax.print.attribute.standard.Finishings"%><%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" import="java.util.*,Test.*,java.lang.reflect.*"%>
<%       request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");   String methodName = request.getParameter("method");try{Class[] argsClass = new Class[2]; argsClass[0] = HttpServletRequest.class;argsClass[1] = HttpServletResponse.class;Class cls = this.getClass();   Method method = cls.getMethod(methodName, argsClass);   Object[] args = new Object[2];args[0] = request;args[1] = response;   BeforeInvoke(methodName);method.invoke(this, args);     }catch( Exception e){e.printStackTrace();HashMap result = new HashMap();result.put("error", -1);result.put("message", e.getMessage());result.put("stackTrace", e.getStackTrace());String json = Test.JSON.Encode(result);response.reset();response.getWriter().write(json);}        finally{AfterInvoke(methodName);}
%>
<%!
//权限管理
protected void BeforeInvoke(String methodName)
{//Hashtable user = GetUser();//if (user.role == "admin" && methodName == "remove") throw .
}
//日志管理
protected void AfterInvoke(String methodName)
{}
//public void SearchEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{       try{  //查询条件String key = request.getParameter("key");//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortField = request.getParameter("sortField");String sortOrder = request.getParameter("sortOrder");HashMap result = new Test.TestDB().SearchEmployees(key, pageIndex, pageSize, sortField, sortOrder);String json = Test.JSON.Encode(result);response.getWriter().write(json);}catch( Exception e){e.printStackTrace();}        finally{}
}public void SaveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String json = request.getParameter("data");ArrayList rows = (ArrayList)Test.JSON.Decode(json); for(int i=0,l=rows.size(); i<l; i++){HashMap row = (HashMap)rows.get(i);String id = row.get("id") != null ? row.get("id").toString() : "";String state = row.get("_state") != null ? row.get("_state").toString() : "";String name = row.get("name").toString();String sqlName = "select * from t_employee where name ='"+name+"'";ArrayList name1 = new Test.TestDB().DBSelect(sqlName);if(name1.size()==0){if(state.equals("added") || id.equals(""))  //新增:id为空,或_state为added{row.put("createtime", new Date());new Test.TestDB().InsertEmployee(row);}else if (state.equals("removed") || state.equals("deleted")){new Test.TestDB().DeleteEmployee(id);}else if (state.equals("modified") || state.equals(""))    //更新:_state为空,或modified{new Test.TestDB().UpdateEmployee(row);}}}response.getWriter().write("ok");
}/***
* 删除员工
*/
public void DeletePerSon(HttpServletRequest request, HttpServletResponse response) throws Exception{String id = request.getParameter("id");String sql="delete t_employee where id='"+id+"'";new TestDB().DBDelete(sql);response.getWriter().write("ok");
}public void RemoveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String idStr = request.getParameter("id");       if (StringUtil.isNullOrEmpty(idStr)) return;String[] ids = idStr.split(",");for (int i = 0, l = ids.length; i < l; i++){String id = ids[i]; new Test.TestDB().DBDelete(id);}
}
public void GetEmployee(HttpServletRequest request, HttpServletResponse response) throws Exception
{String id = request.getParameter("id");HashMap user = new Test.TestDB().GetEmployee(id);String json = Test.JSON.Encode(user);response.getWriter().write(json);
}
public void GetDepartments(HttpServletRequest request, HttpServletResponse response) throws Exception
{ArrayList data = new Test.TestDB().GetDepartments();String json = Test.JSON.Encode(data);response.getWriter().write(json);
}
public void GetPositions(HttpServletRequest request, HttpServletResponse response) throws Exception
{ArrayList data = new Test.TestDB().GetPositions();String json = Test.JSON.Encode(data);response.getWriter().write(json);
}
public void GetEducationals(HttpServletRequest request, HttpServletResponse response) throws Exception
{ArrayList data = new Test.TestDB().GetEducationals();String json = Test.JSON.Encode(data);response.getWriter().write(json);
}
public void GetPositionsByDepartmenId(HttpServletRequest request, HttpServletResponse response) throws Exception
{String id = request.getParameter("id");ArrayList data = new Test.TestDB().GetPositionsByDepartmenId(id);String json = Test.JSON.Encode(data);response.getWriter().write(json);
}public void GetDepartmentEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String dept_id = request.getParameter("dept_id");int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));HashMap result = new Test.TestDB().GetDepartmentEmployees(dept_id, pageIndex, pageSize);String json = Test.JSON.Encode(result);response.getWriter().write(json);
}public void SaveDepartment(HttpServletRequest request, HttpServletResponse response) throws Exception
{String departmentsStr = request.getParameter("departments");ArrayList departments = (ArrayList)Test.JSON.Decode(departmentsStr);for(int i=0,l=departments.size(); i<l; i++){HashMap d = (HashMap)departments.get(i);        new Test.TestDB().UpdateDepartment(d);}
}/
public void FilterCountrys(HttpServletRequest request, HttpServletResponse response) throws Exception
{String key = request.getParameter("key");String value = request.getParameter("value");//建立value的快速哈希索引,便于快速判断是否已经选择String[] values = value.split(",");HashMap valueMap = new HashMap();for(int i=0,l=values.length; i<l; i++){String id = values[i];valueMap.put(id, "1");}//获取数据 String path = request.getSession().getServletContext().getRealPath("/");    String file = path + "/demo/data/countrys.txt";String s = Test.File.read(file);ArrayList data = (ArrayList)Test.JSON.Decode(s);//1)去除已经选择的记录for (int i = data.size() - 1; i >= 0; i--){HashMap o = (HashMap)data.get(i);String id = o.get("id").toString();if (valueMap.get(id) != null){data.remove(i);}}//2)根据名称查找ArrayList result = new ArrayList();for (int i = 0, l = data.size(); i < l; i++){HashMap o = (HashMap)data.get(i);String text = o.get("text").toString();if (StringUtil.isNullOrEmpty(key) || text.toLowerCase().indexOf(key.toLowerCase()) != -1){result.add(o);}}//返回JSON数据String json = Test.JSON.Encode(result);response.getWriter().write(json);
}
public void FilterCountrys2(HttpServletRequest request, HttpServletResponse response) throws Exception
{String key = request.getParameter("key");String value = request.getParameter("value");//获取数据 String path = request.getSession().getServletContext().getRealPath("/");    String file = path + "/demo/data/countrys.txt";String s = Test.File.read(file);ArrayList data = (ArrayList)Test.JSON.Decode(s);//根据名称查找ArrayList result = new ArrayList();for (int i = 0, l = data.size(); i < l; i++){HashMap o = (HashMap)data.get(i);String text = o.get("text").toString();if (StringUtil.isNullOrEmpty(key) || text.toLowerCase().indexOf(key.toLowerCase()) != -1){result.add(o);}}//返回JSON数据String json = Test.JSON.Encode(result);response.getWriter().write(json);
}public void SearchEmployeesByMultiSort(HttpServletRequest request, HttpServletResponse response) throws Exception
{       //查询条件String key = request.getParameter("key");String countrys = request.getParameter("countrys");String sex = request.getParameter("sex");String birthday = request.getParameter("birthday");// System.out.println(birthday);HashMap maps=new HashMap();maps.put("key",key);maps.put("birthday",birthday);maps.put("countrys",countrys);maps.put("sex",sex);//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortString = request.getParameter("sortFields");ArrayList sortFields = new ArrayList();if (!StringUtil.isNullOrEmpty(sortString)){sortFields = (ArrayList)Test.JSON.Decode(sortString);}HashMap result = new Test.TestDB().SearchEmployeesByMultiSort(maps, pageIndex, pageSize, sortFields);String json = Test.JSON.Encode(result);response.getWriter().write(json);}public void SearchEmployeesByJsonP(HttpServletRequest request, HttpServletResponse response) throws Exception
{       //查询条件String key = request.getParameter("key");//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortField = request.getParameter("sortField");String sortOrder = request.getParameter("sortOrder");HashMap result = new Test.TestDB().SearchEmployees(key, pageIndex, pageSize, sortField, sortOrder);String json = Test.JSON.Encode(result);String jsoncallback = request.getParameter("jsoncallback");response.getWriter().write(jsoncallback +"("+json+")");
}%> 

1.2:第二个界面Service,FormService.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" import="java.util.*,Test.*,java.lang.reflect.*"%>
<%       request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");   String methodName = request.getParameter("method");try{Class[] argsClass = new Class[2]; argsClass[0] = HttpServletRequest.class;argsClass[1] = HttpServletResponse.class;Class cls = this.getClass();   Method method = cls.getMethod(methodName, argsClass);   Object[] args = new Object[2];args[0] = request;args[1] = response;   // BeforeInvoke(methodName);method.invoke(this, args);     }catch( Exception e){e.printStackTrace();HashMap result = new HashMap();result.put("error", -1);result.put("message", e.getMessage());result.put("stackTrace", e.getStackTrace());String json = Test.JSON.Encode(result);response.reset();response.getWriter().write(json);}        finally{// AfterInvoke(methodName);}%><%!
public void SaveData(HttpServletRequest request, HttpServletResponse response) throws Exception
{   //获取提交的数据String submitJSON = request.getParameter("submitData");String submitJSONMx = request.getParameter("submitDataMx");HashMap data =new HashMap();data.put("submitJSON",(HashMap)Test.JSON.Decode(submitJSON));data.put("submitJSONMx",(HashMap)Test.JSON.Decode(submitJSONMx));new Test.TestDB2().InsertEmployee(data);}
public void LoadData(HttpServletRequest request, HttpServletResponse response) throws Exception
{String path = request.getSession().getServletContext().getRealPath("/");    String file = path+"/form.txt";String s = Test.File.read(file);HashMap data = (HashMap)Test.JSON.Decode(s);//返回处理结果String json = Test.JSON.Encode(data);response.getWriter().write(json);
}
%> 

1.3:第三个界面上面表格,AjaxService2.jsp

<%@page import="javax.print.attribute.standard.Finishings"%><%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" import="java.util.*,Test.*,java.lang.reflect.*"%>
<%       request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");   String methodName = request.getParameter("method");try{Class[] argsClass = new Class[2]; argsClass[0] = HttpServletRequest.class;argsClass[1] = HttpServletResponse.class;Class cls = this.getClass();   Method method = cls.getMethod(methodName, argsClass);   Object[] args = new Object[2];args[0] = request;args[1] = response;   // BeforeInvoke(methodName);method.invoke(this, args);     }catch( Exception e){e.printStackTrace();HashMap result = new HashMap();result.put("error", -1);result.put("message", e.getMessage());result.put("stackTrace", e.getStackTrace());String json = Test.JSON.Encode(result);response.reset();response.getWriter().write(json);}        finally{// AfterInvoke(methodName);}
%>
<%!
public void SearchEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{       try{  //查询条件String key = request.getParameter("key");//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortField = request.getParameter("sortField");String sortOrder = request.getParameter("sortOrder");HashMap result = new Test.TestDB2().SearchEmployees(key, pageIndex, pageSize, sortField, sortOrder);String json = Test.JSON.Encode(result);response.getWriter().write(json);}catch( Exception e){e.printStackTrace();}        finally{}
}public void SaveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String json = request.getParameter("data");ArrayList rows = (ArrayList)Test.JSON.Decode(json); for(int i=0,l=rows.size(); i<l; i++){HashMap row = (HashMap)rows.get(i);String JyId = row.get("JyId") != null ? row.get("JyId").toString() : "";String state = row.get("_state") != null ? row.get("_state").toString() : "";if(state.equals("added") || JyId.equals(""))    //新增:id为空,或_state为added{new Test.TestDB2().InsertEmployee(row);}else if (state.equals("removed") || state.equals("deleted")){new Test.TestDB2().DeleteEmployee(JyId);}else if (state.equals("modified") || state.equals(""))  //更新:_state为空,或modified{new Test.TestDB2().UpdateEmployee(row);}}response.getWriter().write("ok");
}/***
* 删除员工
*/
public void DeletePerSon(HttpServletRequest request, HttpServletResponse response) throws Exception{String JyId = request.getParameter("JyId");String sql="delete Wz_jy_project where JyId='"+JyId+"'";new TestDB2().DBDelete(sql);response.getWriter().write("ok");}public void RemoveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String JyId = request.getParameter("JyId");       if (StringUtil.isNullOrEmpty(JyId)) return;String[] ids = JyId.split(",");for (int i = 0, l = ids.length; i < l; i++){String id = ids[i]; new Test.TestDB2().DBDelete(id);}
}
public void GetEmployee(HttpServletRequest request, HttpServletResponse response) throws Exception
{String JyId = request.getParameter("JyId");HashMap user = new Test.TestDB2().GetEmployee(JyId);String json = Test.JSON.Encode(user);response.getWriter().write(json);
}public void SearchEmployeesByMultiSort(HttpServletRequest request, HttpServletResponse response) throws Exception
{       //查询条件String key = request.getParameter("key");String year = request.getParameter("year");String version = request.getParameter("version");HashMap maps=new HashMap();maps.put("key",key);maps.put("year",year);maps.put("version",version);//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortString = request.getParameter("sortFields");ArrayList sortFields = new ArrayList();if (!StringUtil.isNullOrEmpty(sortString)){sortFields = (ArrayList)Test.JSON.Decode(sortString);}HashMap result = new Test.TestDB2().SearchEmployeesByMultiSort(maps, pageIndex, pageSize, sortFields);String json = Test.JSON.Encode(result);response.getWriter().write(json);}%> 

1.4:第三个界面下面表格,AjaxService3.jsp

<%@page import="javax.print.attribute.standard.Finishings"%><%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" import="java.util.*,Test.*,java.lang.reflect.*"%>
<%       request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");   String methodName = request.getParameter("method");try{Class[] argsClass = new Class[2]; argsClass[0] = HttpServletRequest.class;argsClass[1] = HttpServletResponse.class;Class cls = this.getClass();   Method method = cls.getMethod(methodName, argsClass);   Object[] args = new Object[2];args[0] = request;args[1] = response;   // BeforeInvoke(methodName);method.invoke(this, args);     }catch( Exception e){e.printStackTrace();HashMap result = new HashMap();result.put("error", -1);result.put("message", e.getMessage());result.put("stackTrace", e.getStackTrace());String json = Test.JSON.Encode(result);response.reset();response.getWriter().write(json);}        finally{// AfterInvoke(methodName);}
%>
<%!
public void SearchEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{       try{  //查询条件String key = request.getParameter("key");//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortField = request.getParameter("sortField");String sortOrder = request.getParameter("sortOrder");HashMap result = new Test.TestDB3().SearchEmployees(key, pageIndex, pageSize, sortField, sortOrder);String json = Test.JSON.Encode(result);response.getWriter().write(json);}catch( Exception e){e.printStackTrace();}        finally{}
}public void SaveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String json = request.getParameter("data");ArrayList rows = (ArrayList)Test.JSON.Decode(json); for(int i=0,l=rows.size(); i<l; i++){HashMap row = (HashMap)rows.get(i);String userNo = row.get("userNo") != null ? row.get("userNo").toString() : "";String state = row.get("_state") != null ? row.get("_state").toString() : "";if(state.equals("added") || userNo.equals(""))    //新增:id为空,或_state为added{row.put("bak2", new Date());new Test.TestDB3().InsertEmployee(row);}else if (state.equals("removed") || state.equals("deleted")){new Test.TestDB3().DeleteEmployee(userNo);}else if (state.equals("modified") || state.equals(""))    //更新:_state为空,或modified{new Test.TestDB3().UpdateEmployee(row);}}response.getWriter().write("ok");
}/***
* 删除员工
*/
public void DeletePerSon(HttpServletRequest request, HttpServletResponse response) throws Exception{String userNo = request.getParameter("userNo");String sql="delete sync_mz_use where userNo='"+userNo+"'";new TestDB3().DBDelete(sql);response.getWriter().write("ok");}public void RemoveEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String idStr = request.getParameter("id");       if (StringUtil.isNullOrEmpty(idStr)) return;String[] ids = idStr.split(",");for (int i = 0, l = ids.length; i < l; i++){String id = ids[i]; new Test.TestDB3().DBDelete(id);}
}
public void GetEmployee(HttpServletRequest request, HttpServletResponse response) throws Exception
{String userNo = request.getParameter("userNo");HashMap user = new Test.TestDB3().GetEmployee(userNo);String json = Test.JSON.Encode(user);response.getWriter().write(json);
}public void GetDepartmentEmployees(HttpServletRequest request, HttpServletResponse response) throws Exception
{String JyId = request.getParameter("JyId");HashMap maps=new HashMap();maps.put("JyId",JyId);int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));//字段排序String sortString = request.getParameter("sortFields");ArrayList sortFields = new ArrayList();if (!StringUtil.isNullOrEmpty(sortString)){sortFields = (ArrayList)Test.JSON.Decode(sortString);}HashMap result = new Test.TestDB3().GetDepartmentEmployees(maps, pageIndex, pageSize, sortFields);String json = Test.JSON.Encode(result);response.getWriter().write(json);
}public void SearchEmployeesByMultiSort(HttpServletRequest request, HttpServletResponse response) throws Exception
{       //查询条件String JyId = request.getParameter("JyId");
//      String datetime = request.getParameter("datetime");
//      String doctorName = request.getParameter("doctorName");HashMap maps=new HashMap();
//     maps.put("key",key);
//      maps.put("datetime",datetime);
//      maps.put("doctorName",doctorName);//分页int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));        //字段排序String sortString = request.getParameter("sortFields");ArrayList sortFields = new ArrayList();if (!StringUtil.isNullOrEmpty(sortString)){sortFields = (ArrayList)Test.JSON.Decode(sortString);}HashMap result = new Test.TestDB3().SearchEmployeesByMultiSort(maps, pageIndex, pageSize, sortFields);String json = Test.JSON.Encode(result);response.getWriter().write(json);}%> 

2:数据处理层,新建一个Test包,

2.1:第一个界面数据处理
package Test;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.*;import java.sql.Clob;
import java.text.DateFormat;
import java.text.SimpleDateFormat;import org.omg.CORBA.Request;public class TestDB {//mysql
//  public static String driver = "com.mysql.jdbc.Driver";
//  public static String url = "jdbc:mysql://localhost/plusoft_test?useUnicode=true&characterEncoding=GBK";
//  public static String user = "root";
//  public static String pwd = "";//sqlserverpublic static String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";public static String url = "jdbc:sqlserver://localhost;DatabaseName=MINIUI_XIEBO;";public static String user = "sa";public static String pwd = "111111";  public String InsertNode(HashMap n) throws Exception{String sql = "insert into plus_file (id, name, type, size, url, pid, createdate, updatedate, folder, num)"+ " values(?,?,?,?,?,?,?,?,?,?)";DBInsert(sql, n);return n.get("id").toString();}public void RemoveNode(HashMap n) throws Exception{String id = n.get("id").toString();Connection conn = getConn();      Statement stmt = conn.createStatement();String sql = "delete from plus_file where id = \""+id+"\"";             stmt.executeUpdate(sql);stmt.close();conn.close();}public void UpdateTreeNode(HashMap n) throws Exception{String sql ="update plus_file " + " set "+    " name = ?,"+   " pid = ?,"+    " num = ?"+" where id = ?";Connection conn = getConn();     PreparedStatement stmt = conn.prepareStatement(sql);    stmt.setString(1, ToString(n.get("name")));stmt.setString(2, ToString(n.get("pid")));stmt.setInt(3, ToInt(n.get("num")));stmt.setString(4, ToString(n.get("id")));stmt.executeUpdate();     stmt.close();conn.close();   }public ArrayList GetDepartments() throws Exception{String sql = "select *"+" from t_department";ArrayList data = DBSelect(sql);return data;}public HashMap GetDepartment(String id) throws Exception{String sql = "select * from t_department where id = '" + id + "'";ArrayList data = DBSelect(sql);return data.size() > 0 ? (HashMap)data.get(0) : null;}public ArrayList GetPositions() throws Exception{String sql = "select * from t_position";ArrayList data = DBSelect(sql);return data;}public ArrayList GetEducationals() throws Exception{String sql = "select * from t_educational";ArrayList data = DBSelect(sql);return data;}public ArrayList GetPositionsByDepartmenId(String departmentId) throws Exception{        String sql = "select * from t_position where dept_id = '" + departmentId + "'";ArrayList dataAll = DBSelect(sql);return dataAll;}public HashMap GetDepartmentEmployees(String departmentId, int index, int size) throws Exception{String sql = "select * from t_employee where dept_id = '" + departmentId + "'";ArrayList dataAll = DBSelect(sql);ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());return result;}public HashMap SearchEmployees(String key, int index, int size, String sortField, String sortOrder) throws Exception{//System.Threading.Thread.Sleep(300);if(key == null) key = "";String sql = "select a.*, b.name dept_name, c.name position_name, d.name educational_name\n"+"from t_employee a \n"+"left join t_department b \n"+"on a.dept_id = b.id \n"+"left join t_position c \n"+"on a.position = c.id \n"+"left join t_educational d \n"+"on a.educational = d.id \n"+"where a.userName like '%" + key + "%' \n";if (StringUtil.isNullOrEmpty(sortField) == false){if ("desc".equals(sortOrder) == false) sortOrder = "asc";sql += " order by " + sortField + " " + sortOrder;}else{sql += " order by creatime desc";}ArrayList dataAll = DBSelect(sql);ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}//record.put("createtime", new Timestamp(100,10,10,1,1,1,1));}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());//minAge, maxAge, avgAgeArrayList ages = DBSelect("select min(age) as minAge, max(age) as maxAge, avg(age) as avgAge from t_employee");HashMap ageInfo = (HashMap)ages.get(0);result.put("minAge", ageInfo.get("minAge"));result.put("maxAge", ageInfo.get("maxAge"));result.put("avgAge", ageInfo.get("avgAge"));
//        return result;}public HashMap GetEmployee(String id) throws Exception{String sql = "select * from t_employee where id = '"+id+"'";ArrayList data = DBSelect(sql);return data.size() > 0 ? (HashMap)data.get(0) : null;}public String InsertEmployee(HashMap user) throws Exception{String id = (user.get("id") == null || user.get("id").toString().equals(""))? UUID.randomUUID().toString() : user.get("id").toString();user.put("id", id);Connection conn = getConn();  String sql = " insert into t_employee (id, loginname, name, age, married, gender, birthday, country, city," +" dept_id, position, createtime, salary, educational, school, email, remarks)"+ " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(user.get("id")));stmt.setString(2, ToString(user.get("loginname")));stmt.setString(3, ToString(user.get("name")));stmt.setInt(4, ToInt(user.get("age")));stmt.setInt(5, ToInt(user.get("married")));stmt.setInt(6, ToInt(user.get("gender")));stmt.setTimestamp(7, ToDate(user.get("birthday")));stmt.setString(8, ToString(user.get("country")));stmt.setString(9, ToString(user.get("city")));stmt.setString(10, ToString(user.get("dept_id")));stmt.setString(11, ToString(user.get("position")));stmt.setTimestamp(12, ToDate(user.get("createtime")));stmt.setString(13, ToString(user.get("salary")));stmt.setString(14, ToString(user.get("educational")));stmt.setString(15, ToString(user.get("school")));stmt.setString(16, ToString(user.get("email")));stmt.setString(17, ToString(user.get("remarks")));stmt.executeUpdate();stmt.close();conn.close();return id;}public void DeleteEmployee(String id) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();String sql = "delete   t_employee where id='"+id+"'";           stmt.executeUpdate(sql);stmt.close();conn.close();}public void UpdateEmployee(HashMap user) throws Exception{HashMap db_user = GetEmployee(user.get("id").toString());Iterator iter = user.entrySet().iterator();while (iter.hasNext()) {Map.Entry entry = (Map.Entry) iter.next();Object key = entry.getKey();Object val = entry.getValue();db_user.put(key, val);}         DeleteEmployee(user.get("id").toString());InsertEmployee(db_user);}public void UpdateDepartment(HashMap d) throws Exception{HashMap db_d = GetDepartment(d.get("id").toString());Iterator iter = d.entrySet().iterator();while (iter.hasNext()) {Map.Entry entry = (Map.Entry) iter.next();Object key = entry.getKey();Object val = entry.getValue();db_d.put(key, val);}      String sql ="update t_department " +    " set "+    " name = ?, "+  " manager = ?, "+   " manager_name = ? "+" where id = ?";Connection conn = getConn();       PreparedStatement stmt = conn.prepareStatement(sql);    stmt.setString(1, ToString(db_d.get("name")));stmt.setString(2, ToString(db_d.get("manager")));stmt.setString(3, ToString(db_d.get("manager_name")));stmt.setString(4, ToString(db_d.get("id")));stmt.executeUpdate();      stmt.close();conn.close();      }    public HashMap SearchEmployeesByMultiSort(HashMap key, int index, int size, ArrayList sortFields) throws Exception{String sql =  "select a.*, b.name dept_name, c.name position_name, d.name educational_name \n"+"from t_employee a \n"+"left join t_department b \n"+"on a.dept_id = b.id \n"+"left join t_position c \n"+"on a.position = c.id \n"+"left join t_educational d \n"+"on a.educational = d.id \n"+"where 1=1  ";if(key.get("key") != null&&key.get("key") !="") sql=sql+"  and a.name like '%" + key.get("key") + "%' ";//       select * from [MINIUI_XIEBO].[dbo].[t_employee] where CONVERT(varchar(50), birthday, 120) like '1987-03%'//if(key.get("birthday") != null&&key.get("birthday") !="") sql=sql+"  and  birthday like '%"+key.get("birthday")+"%' ";if(key.get("birthday") != null&&key.get("birthday") !="") sql=sql+"  and  CONVERT(varchar(50), birthday, 120) like '"+key.get("birthday")+"%'  ";if(key.get("countrys") != null&&key.get("countrys") !="") sql=sql+"  and  country='"+key.get("countrys")+"' ";if(key.get("sex") != null&&key.get("sex") !="") sql=sql+"  and  gender='"+key.get("sex")+"' ";int length = sortFields.size();if (length > 0){for (int i = 0; i < length;i++ ){HashMap record = (HashMap)sortFields.get(i);String sortField = (String)record.get("field");String sortOrder = (String)record.get("dir");if (i == 0){sql += " order by " + sortField + " " + sortOrder;}else{sql += "," + sortField + " " + sortOrder;}}}else{sql += " order by createtime desc";}ArrayList dataAll = DBSelect(sql);   ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}}System.out.println();HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());return result;}/private Connection getConn() throws Exception{      Class.forName(driver).newInstance();Connection conn = null;if(user == null || user.equals("")){conn = java.sql.DriverManager.getConnection(url);}else{conn = java.sql.DriverManager.getConnection(url, user, pwd);}return conn;}        public ArrayList DBSelect(String sql) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();ResultSet rst = stmt.executeQuery(sql);     ArrayList list = ResultSetToList(rst);rst.close();stmt.close();conn.close();return list;}public void DBDelete(String sql) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();stmt.executeUpdate(sql);stmt.close();conn.close();}public void DBInsert(String sql,HashMap node) throws Exception{Connection conn = getConn();PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(node.get("id")));stmt.setString(2, ToString(node.get("name")));stmt.setString(3, ToString(node.get("type")));stmt.setString(4, ToString(node.get("size")));stmt.setString(5, ToString(node.get("url")));stmt.setString(6, ToString(node.get("pid")));stmt.setTimestamp(7, ToDate(node.get("createdate")));stmt.setTimestamp(8, ToDate(node.get("updatedate")));stmt.setInt(9, ToInt(node.get("folder")));stmt.setInt(10, ToInt(node.get("num")));stmt.executeUpdate();stmt.close();conn.close();}private static ArrayList ResultSetToList(ResultSet   rs) throws Exception{        ResultSetMetaData md = rs.getMetaData();int columnCount = md.getColumnCount();ArrayList list = new ArrayList();Map rowData;while(rs.next()){rowData = new HashMap(columnCount);for(int i = 1; i <= columnCount; i++)   {                 Object v = rs.getObject(i);             if(v != null && (v.getClass() == Date.class || v.getClass() == java.sql.Date.class)){Timestamp ts= rs.getTimestamp(i);v = new java.util.Date(ts.getTime());//v = ts;}else if(v != null && v.getClass() == Clob.class){v = clob2String((Clob)v);}rowData.put(md.getColumnName(i),   v);}list.add(rowData);           }return list;}  private static String clob2String(Clob clob) throws Exception {return (clob != null ? clob.getSubString(1, (int) clob.length()) : null);}           private int ToInt(Object o){if(o == null) return 0;double d = Double.parseDouble(o.toString());int i = 0;i -= d;return -i;          }    private String ToString(Object o){if(o == null) return "";return o.toString();}    private Timestamp ToDate(Object o){try{if(o.getClass() == String.class){DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");o = format.parse(o.toString());  return new java.sql.Timestamp(((Date)o).getTime());}return o != null ? new java.sql.Timestamp(((Date)o).getTime()) : null;}catch(Exception ex){return null;}}
}

2.2:第三个界面上面表格数据处理,TestDB2.Java

package Test;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.*;import java.sql.Clob;
import java.text.DateFormat;
import java.text.SimpleDateFormat;import org.omg.CORBA.Request;public class TestDB2 {//mysql
//  public static String driver = "com.mysql.jdbc.Driver";
//  public static String url = "jdbc:mysql://localhost/plusoft_test?useUnicode=true&characterEncoding=GBK";
//  public static String user = "root";
//  public static String pwd = "";//sqlserver的JDBCpublic static String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";public static String url = "jdbc:sqlserver://localhost;DatabaseName=MINIUI_XIEBO;";public static String user = "sa";public static String pwd = "111111";     public HashMap SearchEmployees(String key, int index, int size, String sortField, String sortOrder) throws Exception{//System.Threading.Thread.Sleep(300);if(key == null) key = "";String sql = "select *\n"+"from sync_mz_use  \n"+"where userName like '%" + key + "%' \n";if (StringUtil.isNullOrEmpty(sortField) == false){if ("desc".equals(sortOrder) == false) sortOrder = "asc";sql += " order by " + sortField + " " + sortOrder;}else{sql += " order by userNo desc";}ArrayList dataAll = DBSelect(sql);ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}//record.put("createtime", new Timestamp(100,10,10,1,1,1,1));}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());//minAge, maxAge, avgAge
//        ArrayList ages = DBSelect("select min(age) as minAge, max(age) as maxAge, avg(age) as avgAge from t_employee");
//        HashMap ageInfo = (HashMap)ages.get(0);
//        result.put("minAge", ageInfo.get("minAge"));
//        result.put("maxAge", ageInfo.get("maxAge"));
//        result.put("avgAge", ageInfo.get("avgAge"));
//        return result;}public HashMap GetEmployee(String JyId) throws Exception{String sql = "select * from Wz_jy_project where JyId = '"+JyId+"'";ArrayList data = DBSelect(sql);return data.size() > 0 ? (HashMap)data.get(0) : null;}@SuppressWarnings("unchecked")public String InsertEmployee(HashMap user) throws Exception{//HashMap  user=(HashMap) datas.get("submitJSON");String JyId = (user.get("JyId") == null || user.get("JyId").toString().equals(""))? UUID.randomUUID().toString() : user.get("JyId").toString();user.put("JyId", JyId);Connection conn = getConn();String sql = "insert into Wz_jy_project (JyId,Number,Version,Archive,ArchiveId,Control,AttachDate,Year,SerialNo,OldBeach,NewBeach," +"TestProject,Analyze,Judge,Comparison,AnalysisPeople,AnalysisTime,Audit,AuditTime,Conclusion,ConclusionIsReceived,Remark) " +"values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";PreparedStatement stmt = conn.prepareStatement(sql);stmt.setInt(1,  ToInt(user.get("JyId")));stmt.setString(2, ToString(user.get("Number")));stmt.setString(3, ToString(user.get("Version")));  stmt.setString(4, ToString(user.get("Archive")));stmt.setInt(5, ToInt(user.get("ArchiveId")));stmt.setInt(6,ToInt(user.get("Control")));stmt.setTimestamp(7, ToDate(user.get("AttachDate")));stmt.setInt(8, ToInt(user.get("Year")));stmt.setString(9, ToString(user.get("SerialNo")));stmt.setString(10, ToString(user.get("OldBeach")));stmt.setString(11, ToString(user.get("NewBeach")));stmt.setString(12, ToString(user.get("TestProject")));stmt.setString(13, ToString(user.get("Analyze")));stmt.setString(14, ToString(user.get("Judge")));stmt.setString(15, ToString(user.get("Comparison")));stmt.setInt(16, ToInt(user.get("AnalysisPeople")));stmt.setTimestamp(17, ToDate(user.get("AnalysisTime")));stmt.setInt(18, ToInt(user.get("Audit")));stmt.setTimestamp(19, ToDate(user.get("AuditTime")));stmt.setString(20, ToString(user.get("Conclusion")));stmt.setInt(21, ToInt(user.get("ConclusionIsReceived")));stmt.setString(22, ToString(user.get("Remark")));stmt.executeUpdate();//  System.out.println(stmt.getGeneratedKeys().getObject(1)); ///主键
//      HashMap  usermx=(HashMap) datas.get("submitJSONMx");
//      String sqlmx="INSERT INTO Wz_jy_sample (JyId,Sample,Oldx,Newx,Absolute,Scope,Remark)VALUES( ?, ?, ?, ?, ?, ?, ?)";
//
//      PreparedStatement stmtMx = conn.prepareStatement(sqlmx);
//
//      stmtMx.setString(1, stmt.getGeneratedKeys().getObject(1)+"");
//
//      stmt.setInt(2, ToInt(user.get("JyId")));
//      stmt.setString(3, ToString(user.get("Sample")));
//      stmt.setString(4, ToString(user.get("Oldx")));
//      stmt.setString(5, ToString(user.get("Newx")));
//      stmt.setString(6,ToString(user.get("Absolute")));
//      stmt.setString(7, ToString(user.get("Scope")));
//      stmt.setString(8, ToString(user.get("Remark")));
//
//      stmtMx.executeUpdate();stmt.close();//stmtMx.close();conn.close();return "";}public String InsertEmployee1(HashMap user) throws Exception{String numberId = (user.get("sampleId") == null || user.get("sampleId").toString().equals(""))? UUID.randomUUID().toString() : user.get("numberId").toString();user.put("numberId", numberId);if (user.get("version") == null) user.put("version", "");if (StringUtil.isNullOrEmpty(user.get("archive"))) user.put("archive", 0);Connection conn = getConn(); String sql = "insert into t_project (numberId,version,archive,control,attachDate,year,serialNo,oldBeach,newBeach,testProject,analyze,judge,comparison,remark)"+ " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(user.get("numberId")));stmt.setString(2, ToString(user.get("version")));stmt.setString(3, ToString(user.get("archive")));    stmt.setString(4, ToString(user.get("control")));stmt.setTimestamp(5, ToDate(user.get("attachDate")));stmt.setString(6, ToString(user.get("year")));stmt.setString(7, ToString(user.get("serialNo")));stmt.setString(8, ToString(user.get("oldBeach")));stmt.setString(9, ToString(user.get("newBeach")));stmt.setString(10, ToString(user.get("testProject")));stmt.setString(11, ToString(user.get("analyze")));stmt.setString(12, ToString(user.get("judge")));stmt.setString(13, ToString(user.get("comparison")));stmt.setString(14, ToString(user.get("remark")));stmt.executeUpdate();stmt.close();conn.close();return numberId;}public void DeleteEmployee(String JyId) throws Exception{Connection conn = getConn();       Statement stmt = conn.createStatement();String sql = "delete Wz_jy_project where JyId='"+JyId+"'";          stmt.executeUpdate(sql);stmt.close();conn.close();}public void UpdateEmployee(HashMap user) throws Exception{HashMap db_user = GetEmployee(user.get("JyId").toString());Iterator iter = user.entrySet().iterator();while (iter.hasNext()) {Map.Entry entry = (Map.Entry) iter.next();Object key = entry.getKey();Object val = entry.getValue();db_user.put(key, val);}         DeleteEmployee(user.get("JyId").toString());InsertEmployee(db_user);}public HashMap SearchEmployeesByMultiSort(HashMap key, int index, int size, ArrayList sortFields) throws Exception{String sql =  "select a.*  from Wz_jy_project a \n"+"where 1=1";if(key.get("key") != null&&key.get("key") !="") sql=sql+"  and  a.Control like '%" + key.get("key") + "%' ";if(key.get("year") != null&&key.get("year") !="") sql=sql+"  and  a.Year like '%"+key.get("year")+"%'  ";if(key.get("version") != null&&key.get("version") !="") sql=sql+"  and  a.Version like '%" +key.get("version")+"%'  ";int length = sortFields.size();if (length > 0){for (int i = 0; i < length;i++ ){HashMap record = (HashMap)sortFields.get(i);String sortField = (String)record.get("field");String sortOrder = (String)record.get("dir");if (i == 0){sql += " order by " + sortField + " " + sortOrder;}else{sql += "," + sortField + " " + sortOrder;}}}else{sql += " order by JyId desc";}ArrayList dataAll = DBSelect(sql);   ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());return result;}/private Connection getConn() throws Exception{       Class.forName(driver).newInstance();Connection conn = null;if(user == null || user.equals("")){conn = java.sql.DriverManager.getConnection(url);}else{conn = java.sql.DriverManager.getConnection(url, user, pwd);}return conn;}        public ArrayList DBSelect(String sql) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();ResultSet rst = stmt.executeQuery(sql);     ArrayList list = ResultSetToList(rst);rst.close();stmt.close();conn.close();return list;}public void DBDelete(String sql) throws Exception{     Connection conn = getConn();        Statement stmt = conn.createStatement();stmt.executeUpdate(sql);stmt.close();conn.close();}public void DBInsert(String sql,HashMap node) throws Exception{Connection conn = getConn();PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(node.get("id")));stmt.setString(2, ToString(node.get("name")));stmt.setString(3, ToString(node.get("type")));stmt.setString(4, ToString(node.get("size")));stmt.setString(5, ToString(node.get("url")));stmt.setString(6, ToString(node.get("pid")));stmt.setTimestamp(7, ToDate(node.get("createdate")));stmt.setTimestamp(8, ToDate(node.get("updatedate")));stmt.setInt(9, ToInt(node.get("folder")));stmt.setInt(10, ToInt(node.get("num")));stmt.executeUpdate();stmt.close();conn.close();}private static ArrayList ResultSetToList(ResultSet   rs) throws Exception{        ResultSetMetaData md = rs.getMetaData();int columnCount = md.getColumnCount();ArrayList list = new ArrayList();Map rowData;while(rs.next()){rowData = new HashMap(columnCount);for(int i = 1; i <= columnCount; i++)   {                 Object v = rs.getObject(i);             if(v != null && (v.getClass() == Date.class || v.getClass() == java.sql.Date.class)){Timestamp ts= rs.getTimestamp(i);v = new java.util.Date(ts.getTime());//v = ts;}else if(v != null && v.getClass() == Clob.class){v = clob2String((Clob)v);}rowData.put(md.getColumnName(i),   v);}list.add(rowData);           }return list;}  private static String clob2String(Clob clob) throws Exception {return (clob != null ? clob.getSubString(1, (int) clob.length()) : null);}           private int ToInt(Object o){if(o == null) return 0;double d = Double.parseDouble(o.toString());int i = 0;i -= d;return -i;          }    private String ToString(Object o){if(o == null) return "";return o.toString();}    private Timestamp ToDate(Object o){try{if(o.getClass() == String.class){DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");o = format.parse(o.toString());  return new java.sql.Timestamp(((Date)o).getTime());}return o != null ? new java.sql.Timestamp(((Date)o).getTime()) : null;}catch(Exception ex){return null;}}
}

2.3:第三个界面下面表格数据处理 TestDB3.Java

package Test;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.*;import java.sql.Clob;
import java.text.DateFormat;
import java.text.SimpleDateFormat;import org.omg.CORBA.Request;public class TestDB3 {//mysql
//  public static String driver = "com.mysql.jdbc.Driver";
//  public static String url = "jdbc:mysql://localhost/plusoft_test?useUnicode=true&characterEncoding=GBK";
//  public static String user = "root";
//  public static String pwd = "";//sqlserverpublic static String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";public static String url = "jdbc:sqlserver://localhost;DatabaseName=MINIUI_XIEBO;";public static String user = "sa";public static String pwd = "111111";  public HashMap SearchEmployees(String key, int index, int size, String sortField, String sortOrder) throws Exception{//System.Threading.Thread.Sleep(300);if(key == null) key = "";String sql = "select *\n"+"from sync_mz_use  \n"
//                  +"left join t_department b \n"
//                  +"on a.dept_id = b.id \n"
//                  +"left join t_position c \n"
//                  +"on a.position = c.id \n"
//                  +"left join t_educational d \n"
//                  +"on a.educational = d.id \n"+"where userName like '%" + key + "%' \n";if (StringUtil.isNullOrEmpty(sortField) == false){if ("desc".equals(sortOrder) == false) sortOrder = "asc";sql += " order by " + sortField + " " + sortOrder;}else{sql += " order by userNo desc";}ArrayList dataAll = DBSelect(sql);ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}//record.put("createtime", new Timestamp(100,10,10,1,1,1,1));}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());//minAge, maxAge, avgAge
//        ArrayList ages = DBSelect("select min(age) as minAge, max(age) as maxAge, avg(age) as avgAge from t_employee");
//        HashMap ageInfo = (HashMap)ages.get(0);
//        result.put("minAge", ageInfo.get("minAge"));
//        result.put("maxAge", ageInfo.get("maxAge"));
//        result.put("avgAge", ageInfo.get("avgAge"));
//        return result;}public HashMap GetEmployee(String userNo) throws Exception{String sql = "select * from sync_mz_use where userNo = '"+userNo+"'";ArrayList data = DBSelect(sql);return data.size() > 0 ? (HashMap)data.get(0) : null;}@SuppressWarnings("unchecked")public String InsertEmployee(HashMap user) throws Exception{String userNo = (user.get("userNo") == null || user.get("userNo").toString().equals(""))? UUID.randomUUID().toString() : user.get("userNo").toString();user.put("userNo", userNo);if (user.get("userName") == null) user.put("userName", "");if (StringUtil.isNullOrEmpty(user.get("gender"))) user.put("gender", 0);Connection conn = getConn();    String sql = "insert into sync_mz_use (userNo,userName,depCode,depName,gender,doctorId,doctorName,bak1,bak2,bak3,brch)"+ " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(user.get("userNo")));stmt.setString(2, ToString(user.get("userName")));stmt.setString(3, ToString(user.get("depCode"))); stmt.setString(4, ToString(user.get("depName")));stmt.setString(5, ToString(user.get("gender")));stmt.setString(6, ToString(user.get("doctorId")));stmt.setString(7, ToString(user.get("doctorName")));stmt.setString(8, ToString(user.get("bak1")));stmt.setTimestamp(9, ToDate(user.get("bak2")));stmt.setString(10, ToString(user.get("bak3")));stmt.setString(11, ToString(user.get("brch")));stmt.executeUpdate();stmt.close();conn.close();return userNo;}public void DeleteEmployee(String userNo) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();String sql = "delete sync_mz_use where userNo='"+userNo+"'";        stmt.executeUpdate(sql);stmt.close();conn.close();}public void UpdateEmployee(HashMap user) throws Exception{HashMap db_user = GetEmployee(user.get("userNo").toString());Iterator iter = user.entrySet().iterator();while (iter.hasNext()) {Map.Entry entry = (Map.Entry) iter.next();Object key = entry.getKey();Object val = entry.getValue();db_user.put(key, val);}         DeleteEmployee(user.get("userNo").toString());InsertEmployee(db_user);}public HashMap GetDepartmentEmployees(HashMap JyId, int index, int size, ArrayList sortFields) throws Exception{String sql = "select * from Wz_jy_sample where JyId = '" + JyId.get("JyId") + "'";int length = sortFields.size();if (length > 0){for (int i = 0; i < length;i++ ){HashMap record = (HashMap)sortFields.get(i);String sortField = (String)record.get("field");String sortOrder = (String)record.get("dir");if (i == 0){sql += " order by " + sortField + " " + sortOrder;}else{sql += "," + sortField + " " + sortOrder;}}}else{sql += " order by JyId desc";}ArrayList dataAll = DBSelect(sql);ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());return result;}public HashMap SearchEmployeesByMultiSort(HashMap JyId, int index, int size, ArrayList sortFields) throws Exception{String sql =  "select *  from Wz_jy_sample where JyId = '" + JyId + "'";int length = sortFields.size();if (length > 0){for (int i = 0; i < length;i++ ){HashMap record = (HashMap)sortFields.get(i);String sortField = (String)record.get("field");String sortOrder = (String)record.get("dir");if (i == 0){sql += " order by " + sortField + " " + sortOrder;}else{sql += "," + sortField + " " + sortOrder;}}}else{sql += " order by JyId desc";}ArrayList dataAll = DBSelect(sql);   ArrayList data = new ArrayList();int start = index * size, end = start + size;for (int i = 0, l = dataAll.size(); i < l; i++){HashMap record = (HashMap)dataAll.get(i);if (record == null) continue;if (start <= i && i < end){data.add(record);}}HashMap result = new HashMap();result.put("data", data);result.put("total", dataAll.size());return result;}/private Connection getConn() throws Exception{      Class.forName(driver).newInstance();Connection conn = null;if(user == null || user.equals("")){conn = java.sql.DriverManager.getConnection(url);}else{conn = java.sql.DriverManager.getConnection(url, user, pwd);}return conn;}        public ArrayList DBSelect(String sql) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();ResultSet rst = stmt.executeQuery(sql);     ArrayList list = ResultSetToList(rst);rst.close();stmt.close();conn.close();return list;}public void DBDelete(String sql) throws Exception{Connection conn = getConn();     Statement stmt = conn.createStatement();stmt.executeUpdate(sql);stmt.close();conn.close();}public void DBInsert(String sql,HashMap node) throws Exception{Connection conn = getConn();PreparedStatement stmt = conn.prepareStatement(sql);stmt.setString(1, ToString(node.get("id")));stmt.setString(2, ToString(node.get("name")));stmt.setString(3, ToString(node.get("type")));stmt.setString(4, ToString(node.get("size")));stmt.setString(5, ToString(node.get("url")));stmt.setString(6, ToString(node.get("pid")));stmt.setTimestamp(7, ToDate(node.get("createdate")));stmt.setTimestamp(8, ToDate(node.get("updatedate")));stmt.setInt(9, ToInt(node.get("folder")));stmt.setInt(10, ToInt(node.get("num")));stmt.executeUpdate();stmt.close();conn.close();}private static ArrayList ResultSetToList(ResultSet   rs) throws Exception{        ResultSetMetaData md = rs.getMetaData();int columnCount = md.getColumnCount();ArrayList list = new ArrayList();Map rowData;while(rs.next()){rowData = new HashMap(columnCount);for(int i = 1; i <= columnCount; i++)   {                 Object v = rs.getObject(i);             if(v != null && (v.getClass() == Date.class || v.getClass() == java.sql.Date.class)){Timestamp ts= rs.getTimestamp(i);v = new java.util.Date(ts.getTime());//v = ts;}else if(v != null && v.getClass() == Clob.class){v = clob2String((Clob)v);}rowData.put(md.getColumnName(i),   v);}list.add(rowData);           }return list;}  private static String clob2String(Clob clob) throws Exception {return (clob != null ? clob.getSubString(1, (int) clob.length()) : null);}           private int ToInt(Object o){if(o == null) return 0;double d = Double.parseDouble(o.toString());int i = 0;i -= d;return -i;          }    private String ToString(Object o){if(o == null) return "";return o.toString();}    private Timestamp ToDate(Object o){try{if(o.getClass() == String.class){DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");o = format.parse(o.toString());  return new java.sql.Timestamp(((Date)o).getTime());}return o != null ? new java.sql.Timestamp(((Date)o).getTime()) : null;}catch(Exception ex){return null;}}
}

3:工具类

3.1:JSON.java
package Test;import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import flexjson.*;
import flexjson.transformer.*;public class JSON {public static String Encode(Object obj) {if(obj == null || obj.toString().equals("null")) return null;if(obj != null && obj.getClass() == String.class){return obj.toString();}JSONSerializer serializer = new JSONSerializer();serializer.transform(new DateTransformer("yyyy-MM-dd'T'HH:mm:ss"), Date.class);serializer.transform(new DateTransformer("yyyy-MM-dd'T'HH:mm:ss"), Timestamp.class);return serializer.deepSerialize(obj);}public static Object Decode(String json) {if (StringUtil.isNullOrEmpty(json)) return "";JSONDeserializer deserializer = new JSONDeserializer();deserializer.use(String.class, new DateTransformer("yyyy-MM-dd'T'HH:mm:ss"));      Object obj = deserializer.deserialize(json);if(obj != null && obj.getClass() == String.class){return Decode(obj.toString());}       return obj;}
}

3.2:StringUtil.java

package Test;import java.util.Collection;
import java.util.Iterator;public class StringUtil {public static boolean isNullOrEmpty(Object obj) {    return obj == null || "".equals(obj.toString());}public static String toString(Object obj){if(obj == null) return "null";return obj.toString();}public static String join(Collection s, String delimiter) {StringBuffer buffer = new StringBuffer();Iterator iter = s.iterator();while (iter.hasNext()) {buffer.append(iter.next());if (iter.hasNext()) {buffer.append(delimiter);}}return buffer.toString();}
}

3.3:UnicodeReader.java

package Test;
/**version: 1.1 / 2007-01-25- changed BOM recognition ordering (longer boms first)Original pseudocode   : Thomas WeidenfellerImplementation tweaked: Aki Nieminenhttp://www.unicode.org/unicode/faq/utf_bom.htmlBOMs:00 00 FE FF    = UTF-32, big-endianFF FE 00 00    = UTF-32, little-endianEF BB BF       = UTF-8,FE FF          = UTF-16, big-endianFF FE          = UTF-16, little-endianWin2k Notepad:Unicode format = UTF-16LE
***/import java.io.*;/*** Generic unicode textreader, which will use BOM mark* to identify the encoding to be used. If BOM is not found* then use a given default or system encoding.*/
public class UnicodeReader extends Reader {PushbackInputStream internalIn;InputStreamReader   internalIn2 = null;String              defaultEnc;private static final int BOM_SIZE = 4;/**** @param in  inputstream to be read* @param defaultEnc default encoding if stream does not have *                   BOM marker. Give NULL to use system-level default.*/public UnicodeReader(InputStream in, String defaultEnc) {internalIn = new PushbackInputStream(in, BOM_SIZE);this.defaultEnc = defaultEnc;}public String getDefaultEncoding() {return defaultEnc;}/*** Get stream encoding or NULL if stream is uninitialized.* Call init() or read() method to initialize it.*/public String getEncoding() {if (internalIn2 == null) return null;return internalIn2.getEncoding();}/*** Read-ahead four bytes and check for BOM marks. Extra bytes are* unread back to the stream, only BOM bytes are skipped.*/protected void init() throws IOException {if (internalIn2 != null) return;String encoding;byte bom[] = new byte[BOM_SIZE];int n, unread;n = internalIn.read(bom, 0, bom.length);if ( (bom[0] == (byte)0x00) && (bom[1] == (byte)0x00) &&(bom[2] == (byte)0xFE) && (bom[3] == (byte)0xFF) ) {encoding = "UTF-32BE";unread = n - 4;} else if ( (bom[0] == (byte)0xFF) && (bom[1] == (byte)0xFE) &&(bom[2] == (byte)0x00) && (bom[3] == (byte)0x00) ) {encoding = "UTF-32LE";unread = n - 4;} else if (  (bom[0] == (byte)0xEF) && (bom[1] == (byte)0xBB) &&(bom[2] == (byte)0xBF) ) {encoding = "UTF-8";unread = n - 3;} else if ( (bom[0] == (byte)0xFE) && (bom[1] == (byte)0xFF) ) {encoding = "UTF-16BE";unread = n - 2;} else if ( (bom[0] == (byte)0xFF) && (bom[1] == (byte)0xFE) ) {encoding = "UTF-16LE";unread = n - 2;} else {// Unicode BOM mark not found, unread all bytesencoding = defaultEnc;unread = n;}    //System.out.println("read=" + n + ", unread=" + unread);if (unread > 0) internalIn.unread(bom, (n - unread), unread);// Use given encodingif (encoding == null) {internalIn2 = new InputStreamReader(internalIn);} else {internalIn2 = new InputStreamReader(internalIn, encoding);}}public void close() throws IOException {init();internalIn2.close();}public int read(char[] cbuf, int off, int len) throws IOException {init();return internalIn2.read(cbuf, off, len);}}

四:总结

以上内容就是miniui小案例的全部内容,读者可以在练习该案例前可看miniui官网的案例和示例,在掌握miniui的基本使用后再练习该案例,可能会有更多的收获,该博客是本人第一次写,有不全面的地方还请指正!

MiniUi框架简单实例相关推荐

  1. Dwr 框架简单实例

    Dwr 是一个 Java 开源库,帮助你实现Ajax网站. 它可以让你在浏览器中的Javascript代码调用Web服务器上的Java,就像在Java代码就在浏览器中一样. Dwr 主要包括两部分: ...

  2. Celery框架简单实例

    Python 中可以使用Celery框架 Celery框架是提供异步任务处理的框架,有两种用法,一种:应用程式发布任务消息,后台Worker监听执行,好处在于不影响应用程序继续执行.第二种,设置定时执 ...

  3. java持久层用文件_Java持久层框架MyBatis简单实例

    MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis .本文 ...

  4. Log4j2日志记录框架的使用教程与简单实例

    1.Log4j2的使用教程 1.1 简介 Log4j的1.x版本虽然已经被广泛使用于很多应用程序中,但由于出现内存泄漏等bug,代码难以维护,以及需要使用老版本的jdk等劣势,在2015年8月已经玩完 ...

  5. JUnit5单元测试框架的使用教程与简单实例

    1.JUnit5的使用教程 1.1 简介 JUnit是一个Java语言的单元测试框架.它由Kent Beck和Erich Gamma建立,逐渐成为源于Kent Beck的sUnit的xUnit家族中最 ...

  6. 【CI3.1】CI框架简单使用方法

    CI框架简单使用方法 1.回忆MVC1.1.M:模型,提供数据,保存数据1.2.V:视图,只负责显示,表单form1.3.C:控制器,协调模型和视图1.4.action:动作,是控制器中的方法,用于被 ...

  7. Hibernate搭建开发环境+简单实例(二)

    2019独角兽企业重金招聘Python工程师标准>>> Hibernate是非常典型的持久层框架,持久化的思想是非常值得我们学习和研究的.这篇博文,我们主要以实例的形式学习Hiber ...

  8. java播放器使用教程_java 实现音乐播放器的简单实例

    java 实现音乐播放器的简单实例 实现效果图: 代码如下 package cn.hncu.games; import java.applet.Applet; import java.applet.A ...

  9. Linux C Socket编程原理及简单实例

    部分转自:http://goodcandle.cnblogs.com/archive/2005/12/10/294652.aspx 1.   什么是TCP/IP.UDP? 2.   Socket在哪里 ...

最新文章

  1. SQL2005实现全文检索的步骤 停止数据库的用户连接
  2. Web框架——Flask系列之宏、继承、包含(十八)
  3. windows7系统配置maven环境
  4. Wireshark工作笔记-TCP的状态解析,以及建立连接与关闭连接
  5. hr签核系统可以用python做吗_数字与签核参考流程
  6. vs2008 64位 如何连接64位oracle,vs2008中如何连接服务器上Oracle实例?
  7. URI is not registered (Settings | Languages Frameworks | Schemas and DTDs)怎么解决?
  8. RedisTemplate存数据时指定过期时间
  9. Python简明教程--String
  10. 小程序无法获取用户头像的原因
  11. 中国医学史(第三章 中医药理论体系的初步形成)
  12. 企业为什么要做微信公众号?
  13. html5 js获取设备信息,js怎么获取电脑硬件信息
  14. 【Ubuntu】[待机时间]:修改Ubuntu待机时间
  15. POI - Excel 打印配置
  16. getline()函数详解
  17. HDU1238 Substrings
  18. Eclipse下的Setting property 'source' to '...' did not find a matching property 错误
  19. Jquery绑定focus事件遇到的问题
  20. ae计算机配置要求,CG馒头分享AE cs6对电脑所需配置需求

热门文章

  1. 每日瑜伽用数据构建更有价值的商业模式
  2. 女式瑜伽服-市场现状及未来发展趋势
  3. ERROR: syntax error at end of input
  4. CRM系统和外呼系统的分工
  5. 脑部影像相关概念整理(围绕诊断)
  6. Java实战案例一:图书借阅系统
  7. Selenium系列教程 - 下拉列表处理(select标签、非select标签)
  8. 关于传统以太网的总结
  9. Shader实现顶点动画和UV动画_流动的海水效果
  10. Rollup failed to resolve import “element-plus/es/components“ from “node_modules/element-plus/es/inde