文章已移至:https://blog.csdn.net/baidu_35468322/article/details/79643356

移动之前:

移动之后:

1、控制层

     /**
* 修改排序
*
* @param out
* @author wangsai
*/
@RequestMapping(value = "/upDownMove")
public void updESort(PrintWriter out){
PageData pd=this.getPageData();
try {
pd.put("EDIT_TIME", Tools.date2Str(new Date()));
exampleQuestionService.upDownMove(pd);
out.print("success");
} catch (Exception e) {
e.printStackTrace();
}
out.flush();
}

2、XML

     <!-- 上移下移 -->
<update id="upDownMove" parameterType="pd">
update
<include refid="examQuesTableName"></include>
set
E_SORT = (
select
e.E_SORT
from (
select
E_SORT
from
<include refid="examQuesTableName"></include>
where
ID = #{ID}
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0'
) e
),
EDIT_TIME = #{EDIT_TIME}
where
ID = (
select
i.ID
from (
select
ID
from
<include refid="examQuesTableName"></include>
where
E_SORT = #{E_SORT}
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0'
) i
)
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0';<!-- 正常情况下这句话是没用的 --> update
<include refid="examQuesTableName"></include>
set
E_SORT = #{E_SORT},
EDIT_TIME = #{EDIT_TIME}
where
ID = #{ID}
and
ACTIVE_FALG = '0';<!-- 正常情况下这句话是没用的 -->
</update>

3、html

         <table class="content_main_table">
<thead>
<tr>
<th style="width:50px;">序号</th>
<th>问题</th>
<th style="width: 160px;">移动</th>
<th style="width: 160px;">操作</th>
</tr>
</thead>
<tbody>
<!-- 开始循环 -->
<c:choose>
<c:when test="${not empty examQuesList}">
<c:if test="${QX.cha == 1 }">
<c:forEach items="${examQuesList}" var="ques" varStatus="i">
<tr class="courseList">
<td>${i.index+1}</td>
<td>
<p style="line-height: 30px; color: #000; font-size: 14px;">
${ques.CONTENT}
</p>
</td>
<td>
<c:choose>
<c:when test="${QX.edit != 1}">
无权限
</c:when>
<c:otherwise>
<c:if test="${QX.edit == 1 }">
<a class="saveBtn ${i.index+1 == 1 ? 'canNotClick' : ''}" title="上移" onclick="moveUp(this,'${i.index+1}','${ques.ID}')"><i class='icon-arrow-up'></i></a>
<a class="whiteBtn ${i.index+1 == fn:length(examQuesList) ? 'canNotClick' : ''}" title="下移" onclick="moveDown(this,'${i.index+1}','${ques.ID}')"><i class='icon-arrow-down'></i></a>
</c:if>
</c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="${(QX.edit != 1 && QX.del != 1)}">
无权限
</c:when>
<c:otherwise>
<c:if test="${QX.edit == 1 }">
<a class="a_blue" title="编辑" onclick="edit('${ques.ID}')"><i class='icon-edit'></i></a>
</c:if>
<c:if test="${QX.del == 1 }">
<a class="delBtn" onclick="del('${ques.ID}');" title="删除"><i class='icon-trash'></i></a>
</c:if>
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</c:if>
<c:if test="${QX.cha == 0 }">
<tr>
<td colspan="4">您无权查看</td>
</tr>
</c:if>
</c:when>
<c:otherwise>
<tr class="main_info">
<td colspan="4">没有相关数据</td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
</table>

4、js

         //当前页
var currentPage = "${page.currentPage}";
//每页显示的记录
var showCount = "${page.showCount}"; //上移
function moveUp(obj,index,id) {
if(index == 1){
layer.msg("上移到顶了");
return;
}
var self = $(obj);
var _old = self.closest("tr.courseList");
var _new = self.closest("tr.courseList").prev("tr");
if (_new.length > 0) {
var _temp = _old.html();
_old.empty().append(_new.html());
_new.empty().append(_temp);
}
var eSort = (currentPage-1)*showCount+parseInt(index)-1;
$.post("exampleQuestion/upDownMove.do",{E_SORT:eSort,ID:id,EXAMPLE_ID:"${pd.EXAMPLE_ID}"},function(data){
if(data != 'success'){
layer.alert("移动失败,请重试!");
}
window.location.reload();
});
} //下移
function moveDown(obj,index,id) {
if(index == "${fn:length(examQuesList)}"){
layer.msg("下移到底了");
return;
}
var self = $(obj);
var _old = self.closest("tr.courseList");
var _new = self.closest("tr.courseList").next("tr");
if (_new.length > 0) {
var _temp = _old.html();
_old.empty().append(_new.html());
_new.empty().append(_temp);
}
var eSort = (currentPage-1)*showCount+parseInt(index)+1;
$.post("exampleQuestion/upDownMove.do",{E_SORT:eSort,ID:id,EXAMPLE_ID:"${pd.EXAMPLE_ID}"},function(data){
if(data != 'success'){
layer.alert("移动失败,请重试!");
}
window.location.reload();
});
}

javaWeb上移下移(SpringMVC+Mabits+MySql)的更多相关文章

  1. [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路

    来源于:http://www.jianshu.com/p/5124eef40bf0 [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路 手把手教你整合最优雅SSM框架:S ...

  2. 解决springmvc+mybatis+mysql中文乱码问题【转】

    这篇文章主要介绍了解决java中springmvc+mybatis+mysql中文乱码问题的相关资料,需要的朋友可以参考下 近日使用ajax请求springmvc后台查询mysql数据库,页面显示中文 ...

  3. php修改排序,上移下移

    php修改排序,上移下移 /**    $UpDown //移动方向,up或down    $table //表名    $id //当前移动的ID    $id_col //ID字段的名称    $ ...

  4. SpringMVC+Mybatis+MySQL配置Redis缓存

    SpringMVC+Mybatis+MySQL配置Redis缓存 1.准备环境: SpringMVC:spring-framework-4.3.5.RELEASE-dist Mybatis:3.4.2 ...

  5. Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(四)

    当任何时候觉你得难受了,其实你的大脑是在进化,当任何时候你觉得轻松,其实都在使用以前的坏习惯. 通过前面的学习,你可能大致了解了Quartz,本篇博文为你打开学习SSMM+Quartz的旅程!欢迎上车 ...

  6. SpringMVC + MyBatis + Mysql + Redis(作为二级缓存) 配置

    2016年03月03日 10:37:47 标签: mysql / redis / mybatis / spring mvc / spring 33805 项目环境: 在SpringMVC + MyBa ...

  7. SpringBoot(五)Springmvc+Mybatis+mysql

    为了整合这个花了,好长时间,因为上几个连在一起,在pom文件中有没注释的配置,导致我找这个问题找了好久.下面开始 1,先new project 时选择spring initializr,新建好一个空项 ...

  8. jQuery实现表格行上移下移和置顶

    jQuery实现表格行上移下移和置顶 我们在操作列表数据的时候,需要将数据行排列顺序进行调整,如上移和下移行,将行数据置顶等,这些操作都可以在前端通过点击按钮来完成,并且伴随着简单的动态效果,轻松实现 ...

  9. Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(转)

    通过前面的学习,你可能大致了解了Quartz,本篇博文为你打开学习SSMM+Quartz的旅程!欢迎上车,开始美好的旅程! 本篇是在SSM框架基础上进行的. 参考文章: 1.Quartz学习——Qua ...

随机推荐

  1. mybatis主键返回语句 使用方法,就是实体类.getid即可拿到返回的id

    <insert id="insertSelective" parameterType="com.o2o.Content" useGeneratedKeys ...

  2. mpvue 小程序应用拖动排序

    <template> <div> <div style="width:90%;height:40px;line-height:40px;margin:auto; ...

  3. 转换jmeter测试结果jtl

    #bin/sh filelist=`ls jtl` # 将jtl目录的所有文件列表读取并存入变量 for file in $filelist #遍历处理各个文件 do #文件名形如 test2ad.j ...

  4. 74th LeetCode Weekly Contest Number of Subarrays with Bounded Maximum

    We are given an array A of positive integers, and two positive integers L and R (L <= R). Return ...

  5. STL之vector(不定长数组)

    vector就是一个不定长数组,另外它把一些常用操作“封装”在了vector类型内部.例如,若a是一个vector,可以用a.size()读取它的大小,a.resize()改变大小,a.push_ba ...

  6. java——arr == null || arr.length == 0

    这两者是不同的: arr == null; int[] arr = null; arr.length == 0; int[] arr =new int[0];

  7. cookie 跨域访问

    废话不知道该说些什么...先看代码吧. cookie 是浏览器保存在用户计算机上的少量数据 //读取cookie function getCookie(name) { var arr, reg = n ...

  8. CSS动态伪类选择器温故

    动态伪类选择器 伪类选择器:大家熟悉的:[:link][:visited][:hover][:active]CSS3的伪类选择器分为六种:(1)动态伪类选择器(2)目标伪类选择器(3)语言伪类选择器( ...

  9. SigmoidCrossEntropyLoss

    http://blog.csdn.net/u012235274/article/details/51361290

  10. LeetCode 887.鸡蛋掉落(C++)

    每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去. 你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落下的 ...