文章已移至: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. spring 配置 junit

    package cn.hefen.mall.app; import cn.hefen.mall.app.model.ResultMap; import cn.hefen.mall.app.model. ...

  2. php curl 请求api 接口

    官方文档curl : http://www.runoob.com/php/php-ref-curl.html php开启curl :  ① 打开 php.ini 文件  extension=php_c ...

  3. Java线程同步之静态方法

    静态方法是同步方法:自动加锁,锁的对象是类对象 public static void main(String[] args) { Thread [] threadArr=new Thread[10]; ...

  4. Java json字符串对比

    public class JsonUtil { public static boolean compareJsonText(String str1, String str2) { return com ...

  5. java中检测网络是否相通

    转载:https://www.cnblogs.com/moon-jiajun/p/3454576.html 1 package com.cjj.client; 2 3 import java.io.I ...

  6. Problem04 分解质因数

    题目:将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成: (1)如果这个质数恰等于n,则说明分解质因数的 ...

  7. 【ACM】小猴子下落

    小猴子下落 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 有一颗二叉树,最大深度为D,且所有叶子的深度都相同.所有结点从左到右从上到下的编号为1,2,3,····· ...

  8. js学习笔记 -- Promise

    Promise new Promise( function(resolve, reject) {...} /* executor */  ); executor是带有 resolve 和 reject ...

  9. JavaSE---多线程---线程的生命周期

    1.线程的生命周期:新建.就绪.运行.阻塞.死亡 2.运行状态线程进入阻塞: 1.1 调用sleep方法主动放弃: 1.2 调用线程的suspend方法将线程挂起,不推荐使用: 1.3 线程调用一个阻 ...

  10. Java基础11-数组

    1.使用数组步骤: (1)声明数组 int[] a; (2)分配空间 a=new int[5]; (3)赋值 a[0]=1;  int类型数组如果没有赋值,默认值为0,String类型数组默认为nul ...