Java web开发如何同时提交入多条信息
澳门银河官网
澳门银河官网
当前位置 : 澳门银河官网 > 澳门银河官网网址

Java web开发如何同时提交入多条信息


用的是Springmvc+mybatis 多条数据同时插入如何做到 数据如何绑定

@ResourceMapping"queryRackLists"
public RpcResult<Rack> queryRackLists@JsonParam"rackOlds"
List<RackVo> rackList, ErrorContext error {
    RpcResult<Rack> dataResult = new RpcResult<Rack>;
    try {
        List<Rack> list = rackBo.getRackListrackList;
        dataResult.setDataListlist;
    } catch Exception e {
        logger.error"queryRackLists rackList={}, err : ", JSON.toJSONStringrackList, e;
        dataResult.setSuccessfalse;
        if e instanceof ServiceException {
            addErrorerror, e;
            dataResult.setInfoe.getMessage;
        } else {
            addErrorerror, ErrorCode.Query_Error;
            dataResult.setInfoErrorCode.Query_Error.getMsg;
        }
    }
    return dataResult;

}

类似于这种,传入JSONArray,用list来接收。

前台拼接成json,传到后台转成bean的list。http://blog.csdn.net/zhangdai...

[
      {
        name:zhangsan,
        age:18
    },{
        name:lisi,
        age:5
    },{
        name:wangwu,
        age:1
      }
]
<script type="text/javascript">  
    $document.readyfunction{  
        var saveDataAry=[];  
        var data1={"userName":"test","address":"gz"};  
        var data2={"userName":"ququ","address":"gr"};  
        saveDataAry.pushdata1;  
        saveDataAry.pushdata2;         
        $.ajax{ 
            type:"POST", 
            url:"user/saveUser", 
            dataType:"json",      
            contentType:"application/json",               
            data:JSON.stringifysaveData, 
            success:functiondata{ 
                                       
            } 
         }; 
    };  
</script> 
@RequestMappingvalue = "saveUser", method = {RequestMethod.POST }} 
    @ResponseBody  
    public void saveUser@RequestBody List<User> users { 
         userService.batchSaveusers; 
    } 

广告位

澳门银河官网