分頁存儲過程:
創(chuàng)新互聯(lián)長期為超過千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為順平企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站建設(shè),順平網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
CREATE OR REPLACE PROCEDURE prc_query
(p_tableName in varchar2, --表名
p_strWhere in varchar2, --查詢條件
p_orderColumn in varchar2, --排序的列
p_orderStyle in varchar2, --排序方式
p_curPage in out number, --當(dāng)前頁
p_pageSize in out number, --每頁顯示記錄條數(shù)
p_totalRecords out number, --總記錄數(shù)
p_totalPages out number, --總頁數(shù)
v_cur out pkg_query.cur_query) --返回的結(jié)果集
IS
v_sql VARCHAR2(1000) := ''; --sql語句
v_startRecord Number(4); --開始顯示的記錄條數(shù)
v_endRecord Number(4); --結(jié)束顯示的記錄條數(shù)
BEGIN
--記錄中總記錄條數(shù)
v_sql := 'SELECT TO_NUMBER(COUNT(*)) FROM ' || p_tableName || ' WHERE 1=1';
IF p_strWhere IS NOT NULL or p_strWhere <> '' THEN
v_sql := v_sql || p_strWhere;
END IF;
EXECUTE IMMEDIATE v_sql INTO p_totalRecords;
--驗(yàn)證頁面記錄大小
IF p_pageSize < 0 THEN
p_pageSize := 0;
END IF;
--根據(jù)頁大小計(jì)算總頁數(shù)
IF MOD(p_totalRecords,p_pageSize) = 0 THEN
p_totalPages := p_totalRecords / p_pageSize;
ELSE
p_totalPages := p_totalRecords / p_pageSize + 1;
END IF;
--驗(yàn)證頁號
IF p_curPage < 1 THEN
p_curPage := 1;
END IF;
IF p_curPage > p_totalPages THEN
p_curPage := p_totalPages;
END IF;
--實(shí)現(xiàn)分頁查詢
v_startRecord := (p_curPage - 1) * p_pageSize + 1;
v_endRecord := p_curPage * p_pageSize;
v_sql := 'SELECT * FROM (SELECT A.*, rownum r FROM ' ||
'(SELECT * FROM ' || p_tableName;
IF p_strWhere IS NOT NULL or p_strWhere <> '' THEN
v_sql := v_sql || ' WHERE 1=1' || p_strWhere;
END IF;
IF p_orderColumn IS NOT NULL or p_orderColumn <> '' THEN
v_sql := v_sql || ' ORDER BY ' || p_orderColumn || ' ' || p_orderStyle;
END IF;
v_sql := v_sql || ') A WHERE rownum <= ' || v_endRecord || ') B WHERE r >= '
|| v_startRecord;
DBMS_OUTPUT.put_line(v_sql);
OPEN v_cur FOR v_sql;
END prc_query;
controller:
@Controller
@RequestMapping("/userloginLog")
public class UserLoginLogController {
@Autowired
private IUserLoginLogService userLoginLogService;
@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request,HttpServletResponse response,Model model){
try {
String sql = "";
int pageNo =1;
Map<String, Object> param = new HashMap<String, Object>();
String StrpageNo = request.getParameter("pageNo");
if(StringUtils.isNotBlank(StrpageNo)){
pageNo = Integer.parseInt(StrpageNo);
}
String loginName = request.getParameter("loginName");
String resultCode = request.getParameter("resultCode");
String channelid = request.getParameter("channelid");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
if(StringUtils.isNotBlank(loginName)){
sql+=" and login_name='" + loginName + "'";
model.addAttribute("loginName", loginName);
}
if(StringUtils.isNotBlank(resultCode)){
sql+=" and RESULT_CODE='" + resultCode + "'";
model.addAttribute("resultCode", resultCode);
}
if(StringUtils.isNotBlank(channelid)){
sql+=" and CHANNELID='" + channelid + "'";
model.addAttribute("channelid", channelid);
}
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ){
sql+=" and LOGIN_TIME between to_date('"+startTime+"', 'yyyy-mm-dd hh34:mi:ss') and to_date('"+endTime+"', 'yyyy-mm-dd hh34:mi:ss')";
model.addAttribute("startTime", startTime);
model.addAttribute("endTime", endTime);
}
param.put("tableName", "TL_USER_LOGIN_LOG");
param.put("strWhere", sql);
param.put("curPage", pageNo);
param.put("pageSize", 20);
userLoginLogService.getPrAllUser(param);
//result 為在mybatis xml文件時(shí) 寫的返回結(jié)果名
List<TlUserLoginLog> LoginLogList= (List<TlUserLoginLog>) param.get("result");
int curPage = (Integer) param.get("curPage");
int totalRecords = (Integer) param.get("totalRecords");
int totalPages = (Integer) param.get("totalPages");
model.addAttribute("myPage", curPage);
model.addAttribute("pageNo", curPage);
model.addAttribute("totalCount", totalRecords);
model.addAttribute("totalPage", totalPages);
model.addAttribute("userLoginLogList", LoginLogList);
return "prTest";
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("InfoMessage",
"獲取信息失敗,異常:" + e.getMessage());
return "result";
}
}
}
IUserLoginLogService:
public List<TlUserLoginLog> getPrAllUser(Map map);
UserLoginLogServiceImpl:
@Override
public List<TlUserLoginLog> getPrAllUser(Map map) {
// TODO Auto-generated method stub
return userLoginLogDao.getPrAllUser(map);
}
IUserLoginLogDao:
public List<TlUserLoginLog> getPrAllUser(Map map);
mybitas:
<!-- 調(diào)用存儲過程返回結(jié)果集 -->
<select id="getPrAllUser" statementType="CALLABLE" >
{call prc_query(
#{tableName,mode=IN,jdbcType=VARCHAR},
#{strWhere,mode=IN,jdbcType=VARCHAR},
#{orderColumn,mode=IN,jdbcType=VARCHAR},
#{orderStyle,mode=IN,jdbcType=VARCHAR},
#{curPage,mode=IN,jdbcType=INTEGER},
#{pageSize,mode=IN,jdbcType=INTEGER},
#{totalRecords,mode=OUT,jdbcType=INTEGER},
#{totalPages,mode=OUT,jdbcType=INTEGER},
#{result,mode=OUT,javaType=java.sql.ResultSet,jdbcType=CURSOR,resultMap=com.ai.tyca.dao.IUserLoginLogDao.BaseResultMap}
)}
</select>
JSP:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
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>Basic Form - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="/common/jquery-easyui-1.5.1/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/common/jquery-easyui-1.5.1/themes/icon.css">
<script type="text/javascript" src="/common/jquery-easyui-1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/common/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/common/jquery-easyui-1.5.1/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(function(){
var pageNo = parseInt($("#currentPageNo").val());
var totalPage = parseInt($("#totalPage").val());
if(pageNo == 1 && totalPage == pageNo){
$("#previous").hide();
$("#next").hide();
}else if(pageNo == 1 && totalPage > 1){
$("#previous").hide();
$("#next").show();
}else if(pageNo > 1 && pageNo < totalPage){
$("#previous").show();
$("#next").show();
}else if(pageNo == totalPage && pageNo > 1){
$("#previous").show();
$("#next").hide();
}
$("#previous").click(function(){
$("#pageNo").val(--pageNo);
$("#form1").submit();
});
$("#next").click(function(){
$("#pageNo").val(++pageNo);
$("#form1").submit();
});
$("#firstPage").click(function(){
$("#pageNo").val(1);
$("#form1").submit();
});
$("#lastPage").click(function(){
$("#pageNo").val(totalPage);
$("#form1").submit();
});
$("#selectPage").change(function(){
$("#pageNo").val($(this).val());
$("#form1").submit();
});
$("#selectPage").val(pageNo);
$("#addItemNoteConfirm").click(function(){
//textarea可以使用val獲得值
var notes = $("#itemNote").val();
$("#notes").val(notes);
$("#showForm").submit();
});
$("#goSearch").click(function(){
var start = $("#startRequestTime").val();
var end = $("#endRequestTime").val();
if(start != null && end != null && $.trim(start) != '' && $.trim(end) != ''){
if(start >= end){
alert("開始時(shí)間不能大于結(jié)束時(shí)間!");
return false;
}
}
$("#form1").submit();
});
$("#reset").click(function(){
$('input').val('');
});
$('#dataID').datagrid({
onDblClickRow: function(rowIndex) {
$('#dataID').datagrid('selectRow',rowIndex);
var currentRow =$("#dataID").datagrid("getSelected");
$.ajax({
type:'post',
url:'Security/getSecurity.do',
type:"post",
dataType:"text",
data:{
originalxml:currentRow.originalxml
},
cache:false ,
success:function(orgXML){
$("#dialogorgxml").textbox('setValue',orgXML);
}
});
if(currentRow.loginUserType == "01"){
var loginUserType = "手機(jī)賬號";
}else if(currentRow.loginUserType == "02"){
var loginUserType = "別名賬號";
}
if(currentRow.loginAccountType == "01"){
var loginAccountType ="個人用戶";
}else if(currentRow.loginAccountType == "02"){
var loginAccountType ="企業(yè)用戶";
}
$("#dialogName").textbox('setValue',currentRow.loginName);
$("#dialogTime").textbox('setValue',currentRow.requestTime);
$("#dialogUserType").textbox('setValue',loginUserType);
$("#dialogAccountType").textbox('setValue',loginAccountType);
$("#dialogResult").textbox('setValue',currentRow.result);
$("#dialogDesc").textbox('setValue',currentRow.resultDesc);
$("#dialogRspxml").textbox('setValue',currentRow.rspxml);
$("#dialogChannelid").textbox('setValue',currentRow.channelid);
$("#dialogorgxml").textbox('setValue',currentRow.originalxml);
$('#roleDialog').show().dialog({
left:400,
top:50,
modal : true,
title : '詳細(xì)信息',
modal: true,
closable: true,
draggable: true,
width: 550,
height: 580
});
}
});
});
</script>
</head>
<body>
<form id="form1" name="form1" action="${basePath}userloginLog/getAllUser.do" method="post">
<div >
<div id="p" class="easyui-panel" title="查詢框"
data-options="collapsible:true">
<div >
<table id="searchId" >
<tr>
<td>用戶名:</td>
<td><input class="easyui-textbox" value="${loginName}" name="loginName" ></input></td>
<td>起始時(shí)間:</td>
<td><input id="startRequestTime" class="easyui-datetimebox" value="${startTime}" name="startTime" ></input></td>
<td>結(jié)束時(shí)間:</td>
<td><input id="endRequestTime" class="easyui-datetimebox" value="${endTime}" name="endTime" ></input></td>
<td>請求結(jié)果類型:</td>
<td>
<select id="resultCode" class="easyui-combobox" name="resultCode" >
<option value="" selected>可選擇結(jié)果類型</option>
<option value="0000" <c:if test="${'0000' eq resultCode}">selected</c:if>>成功</option>
<option value="8002" <c:if test="${'8002' eq resultCode}">selected</c:if>>密碼錯誤</option>
<option value="8008" <c:if test="${'8008' eq resultCode}">selected</c:if>>賬號已鎖定</option>
<option value="8001" <c:if test="${'8001' eq resultCode}">selected</c:if>>賬號不存在</option>
<option value="9008" <c:if test="${'9008' eq resultCode}">selected</c:if>>簽名驗(yàn)證錯誤</option>
<option value="9006" <c:if test="${'9006' eq resultCode}">selected</c:if>>認(rèn)證請求報(bào)文格式錯誤</option>
</select>
</td>
<td>平臺:</td>
<td>
<select id="channelid" class="easyui-combobox" name="channelid" >
<option value="" selected>可選擇用戶平臺</option>
<option value="10001" <c:if test="${'10001' eq channelid}">selected</c:if>>店員獎勵系統(tǒng)</option>
<option value="10002" <c:if test="${'10002' eq channelid}">selected</c:if>>直供系統(tǒng)</option>
<option value="10003" <c:if test="${'10003' eq channelid}">selected</c:if>>終端信息平臺</option>
<option value="10004" <c:if test="${'10004' eq channelid}">selected</c:if>>售后</option>
<option value="10005" <c:if test="${'10005' eq channelid}">selected</c:if>>用戶信息管理平臺</option>
</select>
</td>
<td><a id="goSearch" class="easyui-linkbutton" type="submit" iconcls="icon-search" href="javascript:void(0)" onclick="login()">查詢</a></td>
<td><a id="reset" class="easyui-linkbutton" type="reset" iconCls="icon-undo" href="javascript:void(0)" onclick="reset()">重置</a></td>
</tr>
</table>
</div>
</div>
<table id="dataID" class="easyui-datagrid"
data-options="singleSelect:true,fitColumns:true,method:'get'">
<thead>
<tr>
<th data-options="field:'sequence',width:5,align:'center'">序列</th>
<th data-options="field:'loginName',width:10,align:'center'">用戶名</th>
<th data-options="field:'requestTime',width:13,align:'center'">請求時(shí)間</th>
<th data-options="field:'resultDesc',width:10,align:'left'">請求結(jié)果</th>
<th data-options="field:'channelid',width:20,align:'center'">渠道</th>
<th data-options="field:'loginUserType',width:10,align:'center',hidden:true">用戶類型</th>
<th data-options="field:'loginAccountType',width:10,align:'center',hidden:true">賬號類型</th>
<th data-options="field:'originalxml',width:20,align:'left',hidden:true">加密報(bào)文</th>
<th data-options="field:'rspxml',width:20,align:'right',hidden:true">返回報(bào)文</th>
</tr>
</thead>
<tbody>
<c:forEach items="${userLoginLogList}" var="loginList" varStatus="sequence">
<tr>
<td>${sequence.count}</td>
<td>${loginList.loginName }</td>
<td >${loginList.loginTime }</td>
<td>${loginList.resultDesc }</td>
<c:choose>
<c:when test="${'10001' eq loginList.channelid}">
<td>店員獎勵系統(tǒng)</td>
</c:when>
<c:when test="${'10002' eq loginList.channelid}">
<td>直供系統(tǒng)</td>
</c:when>
<c:when test="${'10003' eq loginList.channelid}">
<td>終端信息平臺</td>
</c:when>
<c:when test="${'10004' eq loginList.channelid}">
<td>售后</td>
</c:when>
<c:when test="${'10005' eq loginList.channelid}">
<td>用戶信息管理平臺</td>
</c:when>
<c:otherwise>
<td></td>
</c:otherwise>
</c:choose>
<td>${loginList.loginUserType }</td>
<td>${loginList.loginAccountType }</td>
<td>${loginList.originalxml }</td>
<td>${loginList.rspxml }</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="page_c">
<span class="l inb_a">
</span>
<span class="r page">
<input type="hidden" id="pageNo" name="pageNo" />
<input type="hidden" value="${totalCount}" id="totalCount" name="totalCount" />
<input type="hidden" value="${pageNo}" id="currentPageNo" name="currentPageNo" />
<input type="hidden" value="${totalPage}" id="totalPage" name="totalPage" />
共<var id="pagePiece" class="orange">${totalCount}</var>條<var id="pageTotal">${pageNo}/${totalPage}</var>
<a href="javascript:void(0);" id="firstPage" >首頁</a>
<a href="javascript:void(0);" id="previous" class="hidden" title="上一頁">上一頁</a>
<a href="javascript:void(0);" id="next" class="hidden" title="下一頁">下一頁</a>
<select id="selectPage" >
<c:forEach begin="1" end="${totalPage }" var="myPage">
<option value="${myPage }">第${myPage }頁</option>
</c:forEach>
</select>
<a href="javascript:void(0);" id="lastPage" >尾頁</a>
</span>
</div>
</div>
</form>
<div id="roleDialog" >
<table id="detail" cellpadding="5" >
<tr>
<td>用戶名:</td>
<td><input id="dialogName" class="easyui-textbox" name="loginName" ></input></td>
</tr>
<tr>
<td>請求時(shí)間:</td>
<td><input id="dialogTime" class="easyui-textbox" value="" name="loginName" ></input></td>
</tr>
<tr>
<td>用戶類型:</td>
<td><input id="dialogUserType" class="easyui-textbox" value="" name="loginUserType" ></input></td>
</tr>
<tr>
<td>賬號類型:</td>
<td><input id="dialogAccountType" class="easyui-textbox" value="" name="loginAccountType" ></input></td>
</tr>
<tr>
<td>返回結(jié)果:</td>
<td><input id="dialogDesc" class="easyui-textbox" value="" name="loginName" ></input></td>
</tr>
<tr>
<td>平臺系統(tǒng):</td>
<td><input id="dialogChannelid" class="easyui-textbox" value="" name="loginName" ></input></td>
</tr>
<tr>
<td>返回報(bào)文:</td>
<td><input id="dialogRspxml" data-options="multiline:true" class="easyui-textbox" value="" name="loginName" ></input></td>
</tr>
<tr>
<td>解密后報(bào)文:</td>
<td><input id="dialogorgxml" data-options="multiline:true" class="easyui-textbox" value="" name="loginName" ></input></td>
</tr>
</table>
</div>
</body>
</html>
分享文章:ssm存儲過程分頁
本文URL:http://jinyejixie.com/article30/joggso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、手機(jī)網(wǎng)站建設(shè)、商城網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)