这次讲的是通过复选框,选中,点击提交,并将值chuan到后台controller.这个应用是比较广的,什么批量修改,批量添加,授权管理等等,都用到这个.其实这个还是挺简单的,并没有想象中的那么难,但我看到不少朋友在此处受挫,当然曾经的我也是如此.现在给大家贴个代码分享下吧. 本文中使用的是layui框架,当然也可以不引进它,不过jquery的库还是要的. 该示例环境是spring+springmvc+mybatis plus+jdk8+mysql57+maven3以上+window10(linu…
后端 //添加 @RequestMapping(value = "checkChoise") @ResponseBody ResultJson checkChoise(@RequestBody List<String> arr) { ResultJson resultJson = new ResultJson(); System.out.println("str:"+arr); resultJson.setStatus(0); resultJson.se…
var   ids= new Array();  $("input[class='detailCheck']:checked").each(function(i,k){   var itemId=$(this).attr("itemId");   ids[i]=itemId;  });    $.ajax({   url : ctx + "/test/setNoProcess.do",   type : "get",   da…
在做排序功能的时候需要将一个数组的数据传递到后台,(当时怎么没用json,如果用json就没有那么多的事情了),数据提交采用ajax! 先看代码 js: submitbtn: function () { // 提交 $("#submitbtn").click(function () { $.dialog.confirm("确定要提交吗?", function () { var arr = []; $(".title").each(function…
ajax传递的是{"items":arr},其中arr=[]; 在后台String[] items=req.getParameterValues("items");发现接收不到,打印参数名称 Enumeration<String> names = req.getParameterNames(); while (names.hasMoreElements()) { String string = (String) names.nextElement();…
traditional:true,加上这个就好,默认为false,即允许深度序列化参数,但是servlet api不支持,所有设为true阻止就好了. $.ajax({ type:'post', url:'/lst', async:true, data:{"arr_id":arr_id}, traditional:true, success:function (message) { alert(message) }, error:function () { alert('执行失败');…
//实体类 public class Person { private int ID{get;set;} private string Name{get;set;} private int Age{get;set;} } //前台JS代码var array=new Array(); for(int i=0;i<5;i++) { var option={}; option.ID=1; option.Name="Test"; option.Age=21; array.push(opt…
JSON对象和JSON字符串 在SpringMVC环境中,@RequestBody接收的是一个Json对象的字符串,而不是一个Json对象.然而在ajax请求往往传的都是Json对象,用 JSON.stringify(data)的方式就能将对象变成字符串. 同时ajax请求的时候也要指定dataType: "json",contentType:"application/json" 这样就可以轻易的将一个对象或者List传到Java端! Content-Type 服务…
第二种方法:利用spring mvc的机制,调用对象的get方法,要求对象的属性名和传的参数名字一致(有兴趣的同学看 springmvc源码) 1.将参数名直接写成对象的属性名 $.ajax({ url:"../memberInfo/updateMemberInfo.shtml",   data:{    "id":id,    "channelId":channelId,    "terminalId":terminal, …