- 浏览: 69291 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (42)
- 耗材管理系统 (1)
- OSWorkFlow (2)
- osworkflow api (1)
- jsp 分页插件 (1)
- OsWorkFlow工作流请假实例 (1)
- SSH+DWR (1)
- Java角色权限设计 (1)
- SSH 三大框架整合 (1)
- Spring注解 (1)
- 没有事业的女孩子(一位老总的感言) (1)
- Jdbc介绍 (1)
- struts2 trim截取首尾空格 (1)
- DOS 命令大全 (1)
- SqlServer2000 中各种数据类型允许的最大长度 (1)
- 【收藏版】15款报表工具的总结 (1)
- 获取Java环境的相关信息 (1)
- Java读取二进制文件 (1)
- JAVA 十六进制与字符串的转换 (1)
- struts2 iterator 遍历 map嵌套 (1)
- Spring2文件上传实例 (1)
- JavaScript (1)
- SVN (1)
- JSTL (1)
- ForEach (1)
- Java (1)
- edtFtpJ (3)
- Flash (1)
- 多线程 (1)
- 设计模式 (4)
- jdk (1)
- web.xml (1)
- 算法 (1)
- Spring_MVC (1)
- spring (2)
- Applet (1)
最新评论
-
ybb_dgv:
没有sql
OSworkFlow工作流请假流程实例 -
sunlu:
楼主你好!我运行你的例子时出现个问题使我难以继续!请指教 Un ...
OSworkFlow工作流请假流程实例 -
lotusibm:
文章不错的
Java 角色权限设计 -
dushanggaolou:
解释的很详细。
foreach中循环次数操作 -
Jeenry119:
用的是Netbeans
耗材管理系统
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.pojos.TbHandler"%>
<%@page import="com.pojos.TbGroup"%>
<%@page import="com.pojos.TbPurview,com.sxy.sms.constant.Constant"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="jslib/mytable/mytable1.1.js" charset="gb2312"></script>
<link type="text/css" rel="stylesheet" href="jslib/mytable/css/mytable.css"/>
<link type="text/css" rel="stylesheet" href="jslib/jquery_pagination/pagination.css"/>
<script type="text/javascript" src="jslib/jquery_pagination/jquery.pagination.js"></script>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<style>
table.mytable{
width: 1108px;
}
</style>
<%-- 查询行程单 --%>
<div id="queryDiv">
<form id="queryForm" class="queryForm">
<table class="queryTable">
<tr>
<td>行程单号</td><td><input type="text" id="tripNumber" name="tripNumber" class="isForm"/></td>
<td>电子机票号</td><td><input type="text" name="eTicketNumber" class="isForm"/></td>
<td>操作时间</td><td><input type="text" name="operatorDateTime" class="isForm"
onClick="WdatePicker()"/></td>
</tr>
<c:if test="${!param.isReceive}">
<tr>
<td>录入员</td><td><select id="inputer" name="input.inputClerk.handlerId" class="isForm"><option value=""></option></select></td>
<td>领取员</td><td><select id="receiverSelect" name="receiver.handlerId" class="isForm"><option value=""></option></select></td>
<td>发放员</td><td><select id="sender" name="sender.handlerId" class="isForm"><option value=""></option></select></td>
</tr>
</c:if>
<tr>
<td>录入时间</td><td><input type="text" name="input.inputTime" class="isForm"
onClick="WdatePicker()"/></td>
<td>发放时间</td><td><input type="text" name="sendDateTime" class="isForm"
onClick="WdatePicker()"/></td>
</tr>
<tr>
<td>使用状态</td><td>
<select name="usedState" class="isForm">
<option value=""></option>
<option value="<%=Constant.NORMAL_USED%>"><%=Constant.NORMAL_USED_NAME%></option>
<option value="<%=Constant.BUILD_USED%>"><%=Constant.BUILD_USED_NAME%></option>
<option value="<%=Constant.WASTE_USED%>"><%=Constant.WASTE_USED_NAME%></option>
</select></td>
<td>发放状态</td><td>
<select name="sendState" class="isForm">
<option value=""></option>
<option value="<%=Constant.UN_SEND%>"><%=Constant.UN_SEND_NAME%></option>
<option value="<%=Constant.HAS_SEND%>"><%=Constant.HAS_SEND_NAME%></option>
<option value="<%=Constant.HAS_RECYCLED%>"><%=Constant.HAS_RECYCLED_NAME%></option>
</select></td>
<td><input type="button" value="查询" id="query"/></td>
<td><input type="button" value="重置" id="reset"/></td>
</tr>
</table>
</form>
</div>
<div class="viewResults">
<%
String uri = request.getRequestURI();
uri = uri.substring(uri.lastIndexOf("/"), uri.length());
boolean isSendPage = "/send.jsp".equals(uri);
pageContext.setAttribute("isSendPage",isSendPage);
%>
<table class="mytable">
<thead>
<tr>
<th width="20"><input type="checkbox"/></th>
<c:if test="${hasSendPurview&&isSendPage}">
<th width="48">操作</th>
</c:if>
<th width="40">序</th>
<th width="70"><a xx="tripNumber">行程单号</a></th>
<th width="80"><a xx="eTicketNumber">电子机票号</a></th>
<th width="65"><a xx="usedState">使用状态</a></th>
<th width="65"><a xx="sendState">发放状态</a></th>
<th width="50"><a xx="input.inputClerk.handler">录入员</a></th>
<th width="110"><a xx="input.inputTime">录入时间</a></th>
<th width="100"><a xx="receiver.handler">领取员</a></th>
<th width="55"><a xx="sender.handler">发放员</a></th>
<th width="110"><a xx="sendDateTime">发放时间</a></th>
<th width="60"><a xx="operator">操作员</a></th>
<th width="110"><a xx="operatorDateTime">操作时间</a></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div style="float:left;"><div id="pager" class="pagination" style="float:left;"></div><div style="float:left;font:'宋体';font-size:14px;color:#000;margin-top: 5px;">共<span id="totalNums">0</span>条记录</div></div>
<div style="clear: both;"></div>
<c:if test="${hasSendPurview&&isSendPage}">
<div id="toolbar">
<select id="sendTo"><option value="">选择发送对象</option></select>
<button id="sendTripButton">批量发放</button>
</div>
</c:if>
</div>
<script type="text/javascript">
/*mytable--start*/
var pagesTotal = 0;
alert(${param.isReceive});
$.mytable({
url:"queryTrip.do?p=queryTrip&isSendPage=${isSendPage}&isReceive=${param.isReceive}",
sortCol:['input.inputTime','desc'],
storageSortColAttr:'xx',
afterTableLoad_beforePaginationLoad:function(cfg){
cfg.pagesTotal = pagesTotal;
$('#totalNums').text(pagesTotal);
},
beforeLoad:function(){//mytable查询之前做表单验证
var t1 = $('#tripNumber');
var t2 = $('[name="eTicketNumber"]');
var t3 = $('[name="input.inputTime"]');
var t5 = $('[name="sendDateTime"]');
var r1 = /[0-9]{10,20}/;
var r2 = /[0-9]{12,15}/;
var r3 = /[1-9]{1}[0-9]{3}[-][0-1]{1}[0-9]{1}[-][0-3]{1}[0-9]{1}/;
var e1 = "【行程单号】格式有错,格式为:10~20位的数字,您输入了";
var e2 = "【电子机票号】格式有错,格式为:12~15位的数字,您输入了";
var e3 = "格式为:2011-09-05。";
return validate(
[t1,t2,t3,t5],
[r1,r2,r3,r3],
[e1+t1.val().length+'位。',e2+t2.val().length+'位。','【录入时间】格式有错,'+e3,'【发放时间】格式有错,'+e3]
);
},
toolbar:{
'sendTripButton':function(rows){
var sendTo = $('#sendTo').val();
if(''==sendTo) {
alert("请选择发送对象!");
return;
}
var ids = '';
for(var i = 0; i < rows.length; i++){
ids+=rows[i]+';';
}
$.post("queryTrip.do?p=setSend",{ids:ids,receiver_one:sendTo},function(h){
alert(h);
$("#query").click();
});
}
}
});
/*mytable--end*/
/*显示用户选择框 ---start*/
var inputerV = "<%=Constant.INPUT_TRIP%>";
var receiverV = "<%=Constant.RECEIVE_TRIP%>";
var senderV = "<%=Constant.SEND_TRIP%>";
var selJson = false;//录入员、领取员、发放员的json串,此变量可放入一个公共页面缓存起来
if(selJson){
createOptions($("#inputer"), inputerV);//录入员
createOptions($("#receiverSelect"), receiverV);//领取员
createOptions($("#sender"), senderV);//发放员
createOptions($("#sendTo"), receiverV);//发放对象
} else {
$.post("user.do",{p:"getUsersByPurviewValues", "purviewValues":inputerV+','+receiverV+','+senderV},function(json){
selJson = eval("("+json+")");
createOptions($("#inputer"), inputerV);//录入员
createOptions($("#receiverSelect"), receiverV);//领取员
createOptions($("#sender"), senderV);//发放员
createOptions($("#sendTo"), receiverV);//发放对象
});
}
function createOptions(sel, purviewValue) {
for(var i = 0; i < selJson.length; i++) {
if(purviewValue == selJson[i].purviewValue) {
sel.append("<option value='"+ selJson[i].id +"'>"+selJson[i].username+"</option>");
}
}
}
/*显示用户选择框 ---end*/
</script>
<%-- 查询行程单 --%>
分页 Action 代码:
Java代码
//得到页面传递name值
String orderNum = request.getParameter("orderNum"); // 订单号
String orderStatus = request.getParameter("orderStatus"); // 订单状态
String time = request.getParameter("time"); // 下订单时间
// 定义Map 接收
Map<Object, Object> param = new HashMap<Object, Object>();
param.put("orderNum", orderNum);
param.put("orderStatus", orderStatus);
param.put("time", time);
//注意 map 的键必须是pojo 对象的属性
Nam qneOrderList = qne_OrderService.qneOrderSearchMap(param);
//得到页面传递name值
String orderNum = request.getParameter("orderNum"); // 订单号
String orderStatus = request.getParameter("orderStatus"); // 订单状态
String time = request.getParameter("time"); // 下订单时间
// 定义Map 接收
Map<Object, Object> param = new HashMap<Object, Object>();
param.put("orderNum", orderNum);
param.put("orderStatus", orderStatus);
param.put("time", time);
//注意 map 的键必须是pojo 对象的属性
Nam qneOrderList = qne_OrderService.qneOrderSearchMap(param);
分页Dao 代码:
Java代码
//这个方法你也看得懂是干嘛的
private String getWhereContent2(Map<String, String> param) {
StringBuilder sb = new StringBuilder();
for (Iterator<String> iterator = param.keySet().iterator(); iterator
.hasNext();) {
String key = iterator.next();
if (key != null && !"".equals(key)
/*
* && !"col".equals(key) && !"order".equals(key) &&
* !"rowStart".equals(key) && !"pageSize".equals(key)
*/) {
if (param.get(key) != null && !"".equals(param.get(key))) {
if ("orderNum".equals(key) || "orderStatus".equals(key)
|| "flightNum".equals(key) || "cabin".equals(key)
|| "ticketNum".equals(key) || "pnr".equals(key)
|| "linkmanCellPhone".equals(key)
|| "startCity".equals(key) || "endCity".equals(key)
|| "flightCompany".equals(key)|| "voyageType".equals(key)
|| "linkmanCellPhone".equals(key)
) {
sb.append(" t." + key + " = '" + param.get(key)
+ "' and ");
} else {
sb.append(" t." + key + " like '%" + param.get(key)
+ "%' and ");
}
}
}
}
if (!"".equals(sb.toString())) {
sb.insert(0, " where(");
sb.delete(sb.lastIndexOf("and"), sb.length());
sb.append(") ");
}
return sb.toString();
}
@SuppressWarnings("unchecked")
public List qneOrderSearchMap(Map<String, String> param){
System.out.println("---- -----");
if(null==param || param.isEmpty()) {
return null;
}
int rowStart = 0;//开始
int pageSize = 30;//一页显示数
String col = "time";// 按你pojo对象里面的time属性排序
String order = "asc";//按asc 排序
boolean b = rowStart>=0 && pageSize>0;
String w = getWhereContent2(param);
//String orderStr = ((null!=col&&!"".equals(col) && null!=order&&!"".equals(order))?"order by t." + col + " "+order:"");
String hql = "from QNEOrder as t " + w;
//+orderStr;
// String countSql = "select count(*) from QNEOrder as t" + w;
Session session = getSession();
Query query = session.createQuery(hql);
if(b) {
query.setFirstResult(rowStart);
query.setMaxResults(pageSize);
}
List list=query.list();
return list;
}
//这个方法你也看得懂是干嘛的
private String getWhereContent2(Map<String, String> param) {
StringBuilder sb = new StringBuilder();
for (Iterator<String> iterator = param.keySet().iterator(); iterator
.hasNext();) {
String key = iterator.next();
if (key != null && !"".equals(key)
/*
* && !"col".equals(key) && !"order".equals(key) &&
* !"rowStart".equals(key) && !"pageSize".equals(key)
*/) {
if (param.get(key) != null && !"".equals(param.get(key))) {
if ("orderNum".equals(key) || "orderStatus".equals(key)
|| "flightNum".equals(key) || "cabin".equals(key)
|| "ticketNum".equals(key) || "pnr".equals(key)
|| "linkmanCellPhone".equals(key)
|| "startCity".equals(key) || "endCity".equals(key)
|| "flightCompany".equals(key)|| "voyageType".equals(key)
|| "linkmanCellPhone".equals(key)
) {
sb.append(" t." + key + " = '" + param.get(key)
+ "' and ");
} else {
sb.append(" t." + key + " like '%" + param.get(key)
+ "%' and ");
}
}
}
}
if (!"".equals(sb.toString())) {
sb.insert(0, " where(");
sb.delete(sb.lastIndexOf("and"), sb.length());
sb.append(") ");
}
return sb.toString();
}
@SuppressWarnings("unchecked")
public List qneOrderSearchMap(Map<String, String> param){
System.out.println("---- -----");
if(null==param || param.isEmpty()) {
return null;
}
int rowStart = 0;//开始
int pageSize = 30;//一页显示数
String col = "time";// 按你pojo对象里面的time属性排序
String order = "asc";//按asc 排序
boolean b = rowStart>=0 && pageSize>0;
String w = getWhereContent2(param);
//String orderStr = ((null!=col&&!"".equals(col) && null!=order&&!"".equals(order))?"order by t." + col + " "+order:"");
String hql = "from QNEOrder as t " + w;
//+orderStr;
// String countSql = "select count(*) from QNEOrder as t" + w;
Session session = getSession();
Query query = session.createQuery(hql);
if(b) {
query.setFirstResult(rowStart);
query.setMaxResults(pageSize);
}
List list=query.list();
return list;
}
分页 一个接收查询结果的jsp 其中内容我是以 :
引用
<tr><td>ss</td></tr> <!--这种格式存储的-->
<script>
pagesTotal = ${sum}; // 得到后台处理的最大条数把它传给show.jsp页面 </script>
先说到这儿,分页就可以实现了,而已还有ajax 获取值绑定在select中哦。
ajax 获取值绑定在select中用到的Action方法:
Java代码
public ActionForward getUsersByPurviewValues(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String pvs = request.getParameter("purviewValues");
String[] pvArr = null;
if(pvs != null) {
pvArr = pvs.split(",");
}
String json = iUserSetService.getUsersByPurviewValues(pvArr);
PrintWriter pw = response.getWriter();
pw.print(json);
pw.close();
return null;
}
public ActionForward getUsersByPurviewValues(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String pvs = request.getParameter("purviewValues");
String[] pvArr = null;
if(pvs != null) {
pvArr = pvs.split(",");
}
String json = iUserSetService.getUsersByPurviewValues(pvArr);
PrintWriter pw = response.getWriter();
pw.print(json);
pw.close();
return null;
}
ajax 获取值绑定在select中用到的Dao方法:
Java代码
/**
* 通过权限值得到用户json串
* @param pvArr权限值数组
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public String getUsersByPurviewValues2(String[] pvArr) throws Exception {
String orS = MyUtils.getOrStr(pvArr, "p.value", true);
String temp = orS.length()>0?" WHERE "+orS:"";
String sql ="SELECT"+
" h.handlerID,h.name,p.value "+
"FROM "+
" tb_handler h "+
" INNER JOIN tb_group g ON h.group_id=g.id "+
" LEFT OUTER JOIN tb_group_purview gp ON g.id=gp.group_id "+
" INNER JOIN tb_purview p ON p.id=gp.purview_id "+
temp+
"UNION "+
"SELECT "+
" h.handlerID,h.name,p.value "+
"FROM "+
" tb_handler h "+
" LEFT OUTER JOIN tb_personal_purview pp ON h.handlerID=pp.hanlder_id "+
" INNER JOIN tb_purview p ON p.id=pp.purview_id "+
temp;
Session session = getSession();
List l = session.createSQLQuery(sql).list();
StringBuilder sb = new StringBuilder();
for (Iterator iterator = l.iterator(); iterator.hasNext();) {
Object[] o = (Object[]) iterator.next();
sb.append("{id:'"+ o[0] +"',username:'"+o[1]+"',purviewValue:'"+o[2]+"'},");
}
if(!"".equals(sb.toString())) {
sb.delete(sb.lastIndexOf(","), sb.length());
sb.insert(0, "[");
sb.append("]");
}
return sb.toString();
}
<%@page import="com.pojos.TbHandler"%>
<%@page import="com.pojos.TbGroup"%>
<%@page import="com.pojos.TbPurview,com.sxy.sms.constant.Constant"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="jslib/mytable/mytable1.1.js" charset="gb2312"></script>
<link type="text/css" rel="stylesheet" href="jslib/mytable/css/mytable.css"/>
<link type="text/css" rel="stylesheet" href="jslib/jquery_pagination/pagination.css"/>
<script type="text/javascript" src="jslib/jquery_pagination/jquery.pagination.js"></script>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<style>
table.mytable{
width: 1108px;
}
</style>
<%-- 查询行程单 --%>
<div id="queryDiv">
<form id="queryForm" class="queryForm">
<table class="queryTable">
<tr>
<td>行程单号</td><td><input type="text" id="tripNumber" name="tripNumber" class="isForm"/></td>
<td>电子机票号</td><td><input type="text" name="eTicketNumber" class="isForm"/></td>
<td>操作时间</td><td><input type="text" name="operatorDateTime" class="isForm"
onClick="WdatePicker()"/></td>
</tr>
<c:if test="${!param.isReceive}">
<tr>
<td>录入员</td><td><select id="inputer" name="input.inputClerk.handlerId" class="isForm"><option value=""></option></select></td>
<td>领取员</td><td><select id="receiverSelect" name="receiver.handlerId" class="isForm"><option value=""></option></select></td>
<td>发放员</td><td><select id="sender" name="sender.handlerId" class="isForm"><option value=""></option></select></td>
</tr>
</c:if>
<tr>
<td>录入时间</td><td><input type="text" name="input.inputTime" class="isForm"
onClick="WdatePicker()"/></td>
<td>发放时间</td><td><input type="text" name="sendDateTime" class="isForm"
onClick="WdatePicker()"/></td>
</tr>
<tr>
<td>使用状态</td><td>
<select name="usedState" class="isForm">
<option value=""></option>
<option value="<%=Constant.NORMAL_USED%>"><%=Constant.NORMAL_USED_NAME%></option>
<option value="<%=Constant.BUILD_USED%>"><%=Constant.BUILD_USED_NAME%></option>
<option value="<%=Constant.WASTE_USED%>"><%=Constant.WASTE_USED_NAME%></option>
</select></td>
<td>发放状态</td><td>
<select name="sendState" class="isForm">
<option value=""></option>
<option value="<%=Constant.UN_SEND%>"><%=Constant.UN_SEND_NAME%></option>
<option value="<%=Constant.HAS_SEND%>"><%=Constant.HAS_SEND_NAME%></option>
<option value="<%=Constant.HAS_RECYCLED%>"><%=Constant.HAS_RECYCLED_NAME%></option>
</select></td>
<td><input type="button" value="查询" id="query"/></td>
<td><input type="button" value="重置" id="reset"/></td>
</tr>
</table>
</form>
</div>
<div class="viewResults">
<%
String uri = request.getRequestURI();
uri = uri.substring(uri.lastIndexOf("/"), uri.length());
boolean isSendPage = "/send.jsp".equals(uri);
pageContext.setAttribute("isSendPage",isSendPage);
%>
<table class="mytable">
<thead>
<tr>
<th width="20"><input type="checkbox"/></th>
<c:if test="${hasSendPurview&&isSendPage}">
<th width="48">操作</th>
</c:if>
<th width="40">序</th>
<th width="70"><a xx="tripNumber">行程单号</a></th>
<th width="80"><a xx="eTicketNumber">电子机票号</a></th>
<th width="65"><a xx="usedState">使用状态</a></th>
<th width="65"><a xx="sendState">发放状态</a></th>
<th width="50"><a xx="input.inputClerk.handler">录入员</a></th>
<th width="110"><a xx="input.inputTime">录入时间</a></th>
<th width="100"><a xx="receiver.handler">领取员</a></th>
<th width="55"><a xx="sender.handler">发放员</a></th>
<th width="110"><a xx="sendDateTime">发放时间</a></th>
<th width="60"><a xx="operator">操作员</a></th>
<th width="110"><a xx="operatorDateTime">操作时间</a></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div style="float:left;"><div id="pager" class="pagination" style="float:left;"></div><div style="float:left;font:'宋体';font-size:14px;color:#000;margin-top: 5px;">共<span id="totalNums">0</span>条记录</div></div>
<div style="clear: both;"></div>
<c:if test="${hasSendPurview&&isSendPage}">
<div id="toolbar">
<select id="sendTo"><option value="">选择发送对象</option></select>
<button id="sendTripButton">批量发放</button>
</div>
</c:if>
</div>
<script type="text/javascript">
/*mytable--start*/
var pagesTotal = 0;
alert(${param.isReceive});
$.mytable({
url:"queryTrip.do?p=queryTrip&isSendPage=${isSendPage}&isReceive=${param.isReceive}",
sortCol:['input.inputTime','desc'],
storageSortColAttr:'xx',
afterTableLoad_beforePaginationLoad:function(cfg){
cfg.pagesTotal = pagesTotal;
$('#totalNums').text(pagesTotal);
},
beforeLoad:function(){//mytable查询之前做表单验证
var t1 = $('#tripNumber');
var t2 = $('[name="eTicketNumber"]');
var t3 = $('[name="input.inputTime"]');
var t5 = $('[name="sendDateTime"]');
var r1 = /[0-9]{10,20}/;
var r2 = /[0-9]{12,15}/;
var r3 = /[1-9]{1}[0-9]{3}[-][0-1]{1}[0-9]{1}[-][0-3]{1}[0-9]{1}/;
var e1 = "【行程单号】格式有错,格式为:10~20位的数字,您输入了";
var e2 = "【电子机票号】格式有错,格式为:12~15位的数字,您输入了";
var e3 = "格式为:2011-09-05。";
return validate(
[t1,t2,t3,t5],
[r1,r2,r3,r3],
[e1+t1.val().length+'位。',e2+t2.val().length+'位。','【录入时间】格式有错,'+e3,'【发放时间】格式有错,'+e3]
);
},
toolbar:{
'sendTripButton':function(rows){
var sendTo = $('#sendTo').val();
if(''==sendTo) {
alert("请选择发送对象!");
return;
}
var ids = '';
for(var i = 0; i < rows.length; i++){
ids+=rows[i]+';';
}
$.post("queryTrip.do?p=setSend",{ids:ids,receiver_one:sendTo},function(h){
alert(h);
$("#query").click();
});
}
}
});
/*mytable--end*/
/*显示用户选择框 ---start*/
var inputerV = "<%=Constant.INPUT_TRIP%>";
var receiverV = "<%=Constant.RECEIVE_TRIP%>";
var senderV = "<%=Constant.SEND_TRIP%>";
var selJson = false;//录入员、领取员、发放员的json串,此变量可放入一个公共页面缓存起来
if(selJson){
createOptions($("#inputer"), inputerV);//录入员
createOptions($("#receiverSelect"), receiverV);//领取员
createOptions($("#sender"), senderV);//发放员
createOptions($("#sendTo"), receiverV);//发放对象
} else {
$.post("user.do",{p:"getUsersByPurviewValues", "purviewValues":inputerV+','+receiverV+','+senderV},function(json){
selJson = eval("("+json+")");
createOptions($("#inputer"), inputerV);//录入员
createOptions($("#receiverSelect"), receiverV);//领取员
createOptions($("#sender"), senderV);//发放员
createOptions($("#sendTo"), receiverV);//发放对象
});
}
function createOptions(sel, purviewValue) {
for(var i = 0; i < selJson.length; i++) {
if(purviewValue == selJson[i].purviewValue) {
sel.append("<option value='"+ selJson[i].id +"'>"+selJson[i].username+"</option>");
}
}
}
/*显示用户选择框 ---end*/
</script>
<%-- 查询行程单 --%>
分页 Action 代码:
Java代码
//得到页面传递name值
String orderNum = request.getParameter("orderNum"); // 订单号
String orderStatus = request.getParameter("orderStatus"); // 订单状态
String time = request.getParameter("time"); // 下订单时间
// 定义Map 接收
Map<Object, Object> param = new HashMap<Object, Object>();
param.put("orderNum", orderNum);
param.put("orderStatus", orderStatus);
param.put("time", time);
//注意 map 的键必须是pojo 对象的属性
Nam qneOrderList = qne_OrderService.qneOrderSearchMap(param);
//得到页面传递name值
String orderNum = request.getParameter("orderNum"); // 订单号
String orderStatus = request.getParameter("orderStatus"); // 订单状态
String time = request.getParameter("time"); // 下订单时间
// 定义Map 接收
Map<Object, Object> param = new HashMap<Object, Object>();
param.put("orderNum", orderNum);
param.put("orderStatus", orderStatus);
param.put("time", time);
//注意 map 的键必须是pojo 对象的属性
Nam qneOrderList = qne_OrderService.qneOrderSearchMap(param);
分页Dao 代码:
Java代码
//这个方法你也看得懂是干嘛的
private String getWhereContent2(Map<String, String> param) {
StringBuilder sb = new StringBuilder();
for (Iterator<String> iterator = param.keySet().iterator(); iterator
.hasNext();) {
String key = iterator.next();
if (key != null && !"".equals(key)
/*
* && !"col".equals(key) && !"order".equals(key) &&
* !"rowStart".equals(key) && !"pageSize".equals(key)
*/) {
if (param.get(key) != null && !"".equals(param.get(key))) {
if ("orderNum".equals(key) || "orderStatus".equals(key)
|| "flightNum".equals(key) || "cabin".equals(key)
|| "ticketNum".equals(key) || "pnr".equals(key)
|| "linkmanCellPhone".equals(key)
|| "startCity".equals(key) || "endCity".equals(key)
|| "flightCompany".equals(key)|| "voyageType".equals(key)
|| "linkmanCellPhone".equals(key)
) {
sb.append(" t." + key + " = '" + param.get(key)
+ "' and ");
} else {
sb.append(" t." + key + " like '%" + param.get(key)
+ "%' and ");
}
}
}
}
if (!"".equals(sb.toString())) {
sb.insert(0, " where(");
sb.delete(sb.lastIndexOf("and"), sb.length());
sb.append(") ");
}
return sb.toString();
}
@SuppressWarnings("unchecked")
public List qneOrderSearchMap(Map<String, String> param){
System.out.println("---- -----");
if(null==param || param.isEmpty()) {
return null;
}
int rowStart = 0;//开始
int pageSize = 30;//一页显示数
String col = "time";// 按你pojo对象里面的time属性排序
String order = "asc";//按asc 排序
boolean b = rowStart>=0 && pageSize>0;
String w = getWhereContent2(param);
//String orderStr = ((null!=col&&!"".equals(col) && null!=order&&!"".equals(order))?"order by t." + col + " "+order:"");
String hql = "from QNEOrder as t " + w;
//+orderStr;
// String countSql = "select count(*) from QNEOrder as t" + w;
Session session = getSession();
Query query = session.createQuery(hql);
if(b) {
query.setFirstResult(rowStart);
query.setMaxResults(pageSize);
}
List list=query.list();
return list;
}
//这个方法你也看得懂是干嘛的
private String getWhereContent2(Map<String, String> param) {
StringBuilder sb = new StringBuilder();
for (Iterator<String> iterator = param.keySet().iterator(); iterator
.hasNext();) {
String key = iterator.next();
if (key != null && !"".equals(key)
/*
* && !"col".equals(key) && !"order".equals(key) &&
* !"rowStart".equals(key) && !"pageSize".equals(key)
*/) {
if (param.get(key) != null && !"".equals(param.get(key))) {
if ("orderNum".equals(key) || "orderStatus".equals(key)
|| "flightNum".equals(key) || "cabin".equals(key)
|| "ticketNum".equals(key) || "pnr".equals(key)
|| "linkmanCellPhone".equals(key)
|| "startCity".equals(key) || "endCity".equals(key)
|| "flightCompany".equals(key)|| "voyageType".equals(key)
|| "linkmanCellPhone".equals(key)
) {
sb.append(" t." + key + " = '" + param.get(key)
+ "' and ");
} else {
sb.append(" t." + key + " like '%" + param.get(key)
+ "%' and ");
}
}
}
}
if (!"".equals(sb.toString())) {
sb.insert(0, " where(");
sb.delete(sb.lastIndexOf("and"), sb.length());
sb.append(") ");
}
return sb.toString();
}
@SuppressWarnings("unchecked")
public List qneOrderSearchMap(Map<String, String> param){
System.out.println("---- -----");
if(null==param || param.isEmpty()) {
return null;
}
int rowStart = 0;//开始
int pageSize = 30;//一页显示数
String col = "time";// 按你pojo对象里面的time属性排序
String order = "asc";//按asc 排序
boolean b = rowStart>=0 && pageSize>0;
String w = getWhereContent2(param);
//String orderStr = ((null!=col&&!"".equals(col) && null!=order&&!"".equals(order))?"order by t." + col + " "+order:"");
String hql = "from QNEOrder as t " + w;
//+orderStr;
// String countSql = "select count(*) from QNEOrder as t" + w;
Session session = getSession();
Query query = session.createQuery(hql);
if(b) {
query.setFirstResult(rowStart);
query.setMaxResults(pageSize);
}
List list=query.list();
return list;
}
分页 一个接收查询结果的jsp 其中内容我是以 :
引用
<tr><td>ss</td></tr> <!--这种格式存储的-->
<script>
pagesTotal = ${sum}; // 得到后台处理的最大条数把它传给show.jsp页面 </script>
先说到这儿,分页就可以实现了,而已还有ajax 获取值绑定在select中哦。
ajax 获取值绑定在select中用到的Action方法:
Java代码
public ActionForward getUsersByPurviewValues(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String pvs = request.getParameter("purviewValues");
String[] pvArr = null;
if(pvs != null) {
pvArr = pvs.split(",");
}
String json = iUserSetService.getUsersByPurviewValues(pvArr);
PrintWriter pw = response.getWriter();
pw.print(json);
pw.close();
return null;
}
public ActionForward getUsersByPurviewValues(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String pvs = request.getParameter("purviewValues");
String[] pvArr = null;
if(pvs != null) {
pvArr = pvs.split(",");
}
String json = iUserSetService.getUsersByPurviewValues(pvArr);
PrintWriter pw = response.getWriter();
pw.print(json);
pw.close();
return null;
}
ajax 获取值绑定在select中用到的Dao方法:
Java代码
/**
* 通过权限值得到用户json串
* @param pvArr权限值数组
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public String getUsersByPurviewValues2(String[] pvArr) throws Exception {
String orS = MyUtils.getOrStr(pvArr, "p.value", true);
String temp = orS.length()>0?" WHERE "+orS:"";
String sql ="SELECT"+
" h.handlerID,h.name,p.value "+
"FROM "+
" tb_handler h "+
" INNER JOIN tb_group g ON h.group_id=g.id "+
" LEFT OUTER JOIN tb_group_purview gp ON g.id=gp.group_id "+
" INNER JOIN tb_purview p ON p.id=gp.purview_id "+
temp+
"UNION "+
"SELECT "+
" h.handlerID,h.name,p.value "+
"FROM "+
" tb_handler h "+
" LEFT OUTER JOIN tb_personal_purview pp ON h.handlerID=pp.hanlder_id "+
" INNER JOIN tb_purview p ON p.id=pp.purview_id "+
temp;
Session session = getSession();
List l = session.createSQLQuery(sql).list();
StringBuilder sb = new StringBuilder();
for (Iterator iterator = l.iterator(); iterator.hasNext();) {
Object[] o = (Object[]) iterator.next();
sb.append("{id:'"+ o[0] +"',username:'"+o[1]+"',purviewValue:'"+o[2]+"'},");
}
if(!"".equals(sb.toString())) {
sb.delete(sb.lastIndexOf(","), sb.length());
sb.insert(0, "[");
sb.append("]");
}
return sb.toString();
}
- js分页插件.zip (18.6 KB)
- 下载次数: 16
相关推荐
**jsp分页插件**是一种在网页应用中实现数据分页显示的重要工具,尤其是在处理大量数据时,分页能够提高用户体验,避免一次性加载过多数据导致页面加载缓慢或资源浪费。这款名为"Codejia.Com"的插件因其简单易用和...
**JSP分页插件源码详解** 在Web开发中,数据量大的时候,分页是一种常见的优化用户体验的方式。JSP(JavaServer Pages)作为Java Web应用中的视图层技术,常常需要配合分页功能来展示数据库中的大量数据。本篇将...
**JSP分页插件详解** 在Web开发中,数据量较大的时候,为了提高用户体验,通常会采用分页的方式来展示信息。JSP(JavaServer Pages)作为Java领域中用于动态网页开发的技术,也有多种分页插件可供选择。本文将详细...
**JSP分页插件11.2版详解** 在Web开发中,数据量庞大的页面通常需要进行分页处理,以提高用户体验并减轻服务器压力。`jsp分页插件11.2版`是一个专为Java Web开发者设计的工具,用于帮助他们在JSP页面上轻松实现高效...
JSP分页插件是Web开发中常用的一种工具,主要用于处理大量数据的展示,避免一次性加载所有数据导致页面响应慢或者浏览器崩溃。它允许用户按需加载数据,提高用户体验并减轻服务器负担。本篇文章将深入探讨JSP分页...
"封装好直接使用的jsp分页插件"正是一款针对这一需求设计的工具,它能够简化开发过程,使开发者能够快速实现分页功能,而无需关注底层复杂的逻辑。 该插件适用于jsp与servlet的原生组合,同时对流行的SSH(Struts2 ...
**JSP分页插件V4.0** JSP分页插件是Web开发中用于处理大量数据展示时的一种常用工具。它允许开发者将大数量的数据分批次加载到页面上,提高网页性能并优化用户体验。分页插件V4.0是针对JSP和STRUTS1框架进行优化的...
**JSP分页插件与MySQL数据库的整合应用** 在Web开发中,处理大量数据时,分页是一种常见的优化手段,它可以提高用户体验,避免一次性加载过多数据导致页面响应慢。本教程将详细介绍如何使用JSP分页插件,并以MySQL...
本项目"spring+springmvc+mybatis+jsp分页插件"正是为了解决这个问题而设计的。下面我们将详细探讨这个项目的各个组成部分及其工作原理。 首先,Spring是一个开源的Java框架,它提供了全面的编程和配置模型,简化了...
jspPageControlor分页插件是千里web架构实验室成员--刘捷开发的插件,用来解决jsp程序设计中分页所带来的不便,让程序开发者轻松的实现分页功能。
分页jsp,将该jsp引入需要分页的页面,传入参数就行。通过<jsp:include page="xxx.jsp"/>将页面引入,可实现单个点击分页,也可实现,输入数字分页。
分页插件,页面添加代码;"> ${total }" url="user/findAlluser.do" maxIndexPages="3" maxPageItems="5" export="currentPageNumber=pageNumber" scope="request"> ${user_name }" /> <jsp:include page="../.....
分页插件分页插件分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP 简单分页插件JAVA JSP...
* PageControl, 分页控制, 可以判断总页数和是否有上下页. * * 2008-07-22 加入输出上下分页HTML代码功能 * * @author HX * @version 1.1 2008-9-22 */ public class PageBean { /** 每页显示记录数 */ ...
<br>PageControlor分页插件(次插件仅支持jsp) 包含3个文件: PageControlor分页插件; 分页的帮助文档; 分页插件使用案例; <br>运行使用具体案例时,须注意以下几点: 1、运行环境为jdk(1.4...
1、此插件将数据库查询和分页操作分离开,在查询的时候,不管采用什么设计模式,都必须实现 PageListener接口。 2、接口里面包含四个方法 (1)、public List doSelect(int recordStart,int sizePage),参数...
【描述】:这篇博客介绍了一个自定义的jsp分页插件,它不仅实现了基本的分页功能,还集成了JSON和Ajax技术,以支持更丰富的交互体验。同时,它提供了联合查询、模糊查询和条件查询的能力,增强了数据检索的灵活性和...
本篇将详细介绍如何在JSP(JavaServer Pages)环境中,结合Oracle数据库实现分页功能,并通过一个名为"jsp分页 oracle 插件demo"的示例来演示具体步骤。 首先,我们需要了解JSP分页的基本原理。在JSP中,分页通常...