zoukankan      html  css  js  c++  java
  • SpringMVC解决前台传入的数组或集合类型数据

    1前台处理如下:

    $.ajax({
    url:"saveMapInfo",
    type:"POST",
    dataType:"json",
    contentType:'application/json;charset=utf-8',
    data:JSON.stringify(dti),
    success:function(data){
    if(data.code==0){
    $.messager.show({
    title:'提示',
    msg:'保存成功',
    timeout:10000,
    showType:'slide'
    });
    $('#table').datagrid('reload','${ctx}/listMapInfo');
    }else{
    showError(data.info?data.info:'保存失败!');
    }
    },
    error:function(data){
    showError('保存失败!');
    }
    });

    其中dti是需要传入的数组或集合对象

    2后台接收

    @RequestMapping("/saveMapInfo")
    @ResponseBody
    public JsonResult saveMapInfo(@RequestBody Map<String,DataTableInfo> dti) throws JsonGenerationException, JsonMappingException, IOException
    {
    boolean br=this.fullTextSearchService.saveMapInfo(dti);
    JsonResult info=new JsonResult();
    info.setCode(br?0:1);
    return info;
    }

    使用的是@RequestBody注解

    版权声明:如需转载,请注明!PS:如是转载随便,请忽略
  • 相关阅读:
    nginx
    mysql
    intelij maven
    redis命令大全
    绑定touch事件后click无效,vue项目解决棒法
    新的用法
    img
    vuedragable
    自己总结
    vuex的项目在id中不能运行
  • 原文地址:https://www.cnblogs.com/zwdx/p/7234275.html
Copyright © 2011-2022 走看看