文章已移至: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. Javaweb 实现分页功能

    package cn.zr.testpage.entity; public class User { private String name; private int age; private Str ...

  2. windows 常用 命令

    Hyper-v管理               virtmgmt.msc 网络                         ncpa.cpl windows 远程登陆    mstsc.cpl C ...

  3. C#后端调用WebApi地址

    using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using Syst ...

  4. Java中的String、StringBuffer和StringBuilder的区别

    类型  是否可变  线程安全  能否频繁修改  String  不可变  安全  否  StringBuffer  可变  安全  能  StringBuilder  可变  不安全  能 1.可变与 ...

  5. Vue自定义指令实现按钮级权限控制功能

    思路: 登录:当用户填写完账号和密码后向服务端验证是否正确,验证通过之后,服务端会返回一个token,拿到token之后(我会将这个token存贮到sessionStorage中,保证刷新页面后能记住 ...

  6. 转 Celery 使用

    http://www.mamicode.com/info-detail-1798782.html https://blog.csdn.net/lu1005287365/article/details/ ...

  7. appium连接夜神模拟器方法总结

    使用appium连接模拟器前提条件:appium环境已经搭建完毕,搭建步骤请参考我的博客:appium手机自动化环境搭建 1.下载并安装夜神模拟器:https://www.yeshen.com/ 2. ...

  8. JVM发展史和Java运行时内存区域

    目前三大主流JVM: Sun HotSpot:Sun于1997年收购Longview Technologies公司所得.Sun于2009年被Oracle收购. BEA JRockit:BEA于2002 ...

  9. Linux环境编程--waitpid与fork与execlp

    waitpid waitpid(等待子进程中断或结束) 表头文件 #include<sys/types.h> #include<sys/wait.h> 定义函数 pid_t w ...

  10. eclipse把局部变量提为全局变量的快捷键是什么

    没有缺省定义的直接快捷键,或者就按Ctrl+1按照melord说的那样做,或者自己在Preference/General/Keys自己对Convert Local Variable to Feild进 ...