ssm 儲存過程分頁
分頁儲存過程:
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, --當前頁
p_pageSize in out number, --每頁顯示記錄條數
p_totalRecords out number, --總記錄數
p_totalPages out number, --總頁數
v_cur out pkg_query.cur_query) --返回的結果集
IS
v_sql VARCHAR2(1000) := ''; --sql語句
v_startRecord Number(4); --開始顯示的記錄條數
v_endRecord Number(4); --結束顯示的記錄條數
BEGIN
--記錄中總記錄條數
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;
--驗證頁面記錄大小
IF p_pageSize < 0 THEN
p_pageSize := 0;
END IF;
--根據頁大小計算總頁數
IF MOD(p_totalRecords,p_pageSize) = 0 THEN
p_totalPages := p_totalRecords / p_pageSize;
ELSE
p_totalPages := p_totalRecords / p_pageSize + 1;
END IF;
--驗證頁號
IF p_curPage < 1 THEN
p_curPage := 1;
END IF;
IF p_curPage > p_totalPages THEN
p_curPage := p_totalPages;
END IF;
--實現分頁查詢
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 hh24:mi:ss') and to_date('"+endTime+"', 'yyyy-mm-dd hh24: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檔案時 寫的返回結果名
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:
<!-- 呼叫儲存過程返回結果集 -->
<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("開始時間不能大於結束時間!");
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 = "手機賬號";
}else if(currentRow.loginUserType == "02"){
var loginUserType = "別名賬號";
}
if(currentRow.loginAccountType == "01"){
var loginAccountType ="個人使用者";
}else if(currentRow.loginAccountType == "02"){
var loginAccountType ="企業使用者";
}
$("#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 : '詳細資訊',
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 style="width:100%;height:95%" >
<div id="p" class="easyui-panel" title="查詢框" style="width:99%;height:100px;"
data-options="collapsible:true">
<div style="width:100%;height:100%;">
<table id="searchId" style="width:100%;height:50px;">
<tr>
<td>使用者名稱:</td>
<td><input class="easyui-textbox" style="width: 140px;" value="${loginName}" name="loginName" ></input></td>
<td>起始時間:</td>
<td><input id="startRequestTime" class="easyui-datetimebox" style="width: 140px;" value="${startTime}" name="startTime" ></input></td>
<td>結束時間:</td>
<td><input id="endRequestTime" class="easyui-datetimebox" style="width: 140px;" value="${endTime}" name="endTime" ></input></td>
<td>請求結果型別:</td>
<td>
<select id="resultCode" class="easyui-combobox" name="resultCode" style="width:150px">
<option value="" selected>可選擇結果型別</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>>簽名驗證錯誤</option>
<option value="9006" <c:if test="${'9006' eq resultCode}">selected</c:if>>認證請求報文格式錯誤</option>
</select>
</td>
<td>平臺:</td>
<td>
<select id="channelid" class="easyui-combobox" name="channelid" style="width:150px">
<option value="" selected>可選擇使用者平臺</option>
<option value="10001" <c:if test="${'10001' eq channelid}">selected</c:if>>店員獎勵系統</option>
<option value="10002" <c:if test="${'10002' eq channelid}">selected</c:if>>直供系統</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" style="width:99%;height:95%"
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'">請求時間</th>
<th data-options="field:'resultDesc',width:10,align:'left'">請求結果</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">加密報文</th>
<th data-options="field:'rspxml',width:20,align:'right',hidden:true">返回報文</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>店員獎勵系統</td>
</c:when>
<c:when test="${'10002' eq loginList.channelid}">
<td>直供系統</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>
相關推薦
ssm 儲存過程分頁
分頁儲存過程: CREATE OR REPLACE PROCEDURE prc_query (p_tableName in varchar2, --表名 p_strWhere in varchar
SQL儲存過程分頁與遊標使用
儲存過程: CREATE procedure p_splitpage @sql nvarchar(4000), --要執行的sql語句 @page int=1, --要顯示的頁碼 @pageSize int,&n
sql 帶輸出引數的儲存過程分頁
USE [test] GO /****** Object: StoredProcedure [dbo].[Proc_Paging] Script Date: 2018/10/8/週一 8:26:16 ******/ SET ANSI_NULLS ON GO SE
Sql server動態載入儲存過程--分頁
create procedure [dbo].[pro_getStu] ( @pindex int, --最小是1,第1頁 @psize int, @name nvarchar, @dbcount int&n
mvc+webservice+儲存過程分頁
1.建立資料庫 create database Persion 2.建立資料表 create table Student( id int primary key identity, Name varchar(50), Pass varchar(50) ) 3.往表中插入資料 ins
儲存過程分頁查詢(ORACLE)
CREATE OR REPLACE PACKAGE PKG_QUERY_PAGEDATA IS -- 儲存過程分頁查詢包. -- 原創 : 三界. --
mysql-mybatis 儲存過程-分頁查詢
1.建立表 CREATE TABLE EASYBUY_PRODUCT( `ep_id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '自動編號(標識列),主鍵', `ep_name`
Oracle使用儲存過程分頁
今天我要說的就是基於Oracle儲存過程的一種簡單的分頁方式,首先就是頁面前端發起對分頁的請求,然後向Oracle儲存過程中傳入頁面當前數,頁面大小,查詢的SQL語句,而儲存過程返回來的則是資料總條數和當前頁面要顯示的資料集合。形式如下所示: proced
簡單的SQL儲存過程分頁
USE [testActice] GO /****** Object: StoredProcedure [dbo].[getpagelist] Script Date: 06/12/2017 1
Gridview各種功能+AspNetPager+Ajax實現無重新整理儲存過程分頁
儲存過程: GetProductsCount1: CREATE PROCEDURE GetProductsCount1 AS
MyBatis,MySql儲存過程分頁查詢
前言 如果涉及到同一臺機器上不同庫不同表的關聯查詢,可以通過 資料庫名.表名 的形式來進行跨庫查詢,若不用外掛,這時可以通過儲存過程來完成查詢。 編寫儲存過程 以學生資訊查詢為例,例如有兩個庫。 學生庫student(學生資訊表 stu_info)
【乾貨】SqlServer 總結幾種儲存過程分頁的使用
就我而言寫程式碼最煩的就是處理資料,其中之一就是分頁的使用。 有的程式碼寫多了,總結出一套適用自己的分頁方法;有的查一下資料借鑑一下套用起來也達到目的。 那麼小編在這裡給大家總結幾個方法供大家做一下參考。 分頁方法一: SET ANSI_NULLS ON GO SET QUOTED_IDENT
SSM框架下分頁的實現(封裝page.java和List<?>)
添加 interface jsp頁面 har show 初始化 ring array dex 之前寫過一篇博客 java分頁的實現(後臺工具類和前臺jsp頁面),介紹了分頁的原理。 今天整合了Spring和SpringMVC和MyBatis,做了增刪改查和分頁,之前的邏輯
sqlserver存儲過程分頁記錄
null pid lte sql exe 分頁 總頁數 end begin USE [HK_ERP]GO/****** Object: StoredProcedure [dbo].[GetPageBillsByShopID] Script Date: 2018/10
SSM框架實現分頁查詢
BookDaoMapper.java /** * 根據多條件(圖書分類,圖書名稱,是否借閱)動態查詢圖書資訊 * * @param bookType * 圖書分類 * @param bookName * 圖書名稱 *
SSM —— Jstl自制分頁標籤
首先需要兩個實體工具類 page省略get和set public class Page<T> { private int total; // 總條數 private int page; // 當前頁 private int size;
SSM框架下分頁的實現(封裝page.java和List)
1 <%@page import="com.bwlu.common.Page"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%>
ssm框架實現分頁(limit)
pojo層新建類PageBean package com.qut.pojo; import java.util.List; public class PageBean<T>{
阿里雲物件儲存服務,OSS使用經驗總結,圖片儲存,分頁查詢
阿里雲OSS-使用經驗總結,儲存,賬號-許可權,分頁,縮圖,賬號切換最近專案中,需要使用雲端儲存,最後選擇了阿里雲-物件儲存服務OSS。總的來說,比較簡單,但是仍然遇到了幾個問題,需要總結下。1.OSS總的使用介紹 https://help.aliyun.com/docum
SSM框架實現分頁,返回分頁的JSON資料
先看一下返回的JSON資料: { "pagNum": 1, "pageSize": 5, "totalRecord": 12, "totalPage": 3,