Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 为什么';如果我只更改了一行,我的数据存储是否会将更改发送回服务器?_Spring Mvc_Extjs4.2 - Fatal编程技术网

Spring mvc 为什么';如果我只更改了一行,我的数据存储是否会将更改发送回服务器?

Spring mvc 为什么';如果我只更改了一行,我的数据存储是否会将更改发送回服务器?,spring-mvc,extjs4.2,Spring Mvc,Extjs4.2,我有一个问题,我无法独自解决。非常感谢你的帮助。 我们开始: 如果我在我的网格中编辑多行,我总是会在控制器中得到一个bean列表,以便进一步处理…例如。保存更改,但如果仅编辑一行,则返回一个空列表或列表为空。仅当我编辑超过1行时,它才起作用 这是我的店铺和代理: var billRecordStore = null; function createbillRecordStore() { var billRecordProxy = new Ext.data.HttpProxy({

我有一个问题,我无法独自解决。非常感谢你的帮助。 我们开始: 如果我在我的网格中编辑多行,我总是会在控制器中得到一个bean列表,以便进一步处理…例如。保存更改,但如果仅编辑一行,则返回一个空列表或列表为空。仅当我编辑超过1行时,它才起作用

这是我的店铺和代理:

 var billRecordStore = null;
    function createbillRecordStore() {



var billRecordProxy = new Ext.data.HttpProxy({
            api : {
                read : applicationPath + '/filterRecords',
                update : applicationPath + '/updateRecords'
            },
            type : 'json',
            reader : {
                type : 'json',
                root : 'data',
                idProperty : 'brid',
                totalProperty : 'total'
            },
            writer : {
                type : 'json'
            },
            actionMethods: {
                create: 'POST', read: 'POST', update: 'POST', destroy: 'POST'
            },
            simpleSortMode: true
        });

        billRecordStore = Ext.create('Ext.data.Store', {
            pageSize : 25,
            model : 'billRecordModel',
            storeId : 'billRecordStore',
            proxy : billRecordProxy,
            remoteSort : false,
            autoLoad : false

        });
    }
这是我的SpringMVC控制器:

 @ResponseBody  
 @RequestMapping(value = "/updateRecords", method =
 {RequestMethod.POST, RequestMethod.GET}, produces =
 "application/json")    
 public ResponseWrapper updateBillrecord(
     @RequestBody List<BillRecordsDTO> dirtyBillRecords
 ) { 
     if (dirtyBillRecords != null && dirtyBillRecords.size() > 0)
     {
         billRecordService.updateBillRecords(dirtyBillRecords);
     }
  return null;  
 }
有什么想法吗?你需要更多的信息吗?告诉我。 事先非常感谢。
edfred

查看中的
allowSingle
配置

默认情况下,JSON编写器将单个记录作为对象发送,而将多个记录作为数组发送。将allowSingle设置为false会告诉编写器始终将请求数据包装到数组中,而不管写入的记录数是多少


编辑:你应该可以通过查看帖子看到这一点。在当前配置中,您应该看到针对一个记录发送的请求与针对多个记录发送的请求之间存在显著差异。但是,一旦将
allowSingle
config切换为false,除了发送的数组的大小之外,请求看起来应该基本相同。

Hi existdisle。这就是解决办法。非常感谢你。现在它工作得很好。我像那样更改了编写器。
…编写器:{type:'json',allowSingle:false}…
祝您有愉快的一天。
POST http://localhost:8080/servicetool/updateRecords?_dc=1384181576575 400 (Bad Request) ext-all-debug.js:32379
Ext.define.request ext-all-debug.js:32379
Ext.define.doRequest ext-all-debug.js:71730
Ext.define.update ext-all-debug.js:71455
Ext.define.runOperation ext-all-debug.js:74757
Ext.define.start ext-all-debug.js:74704
Ext.define.batch ext-all-debug.js:42884
Ext.define.sync ext-all-debug.js:43606
Ext.define.save ext-all-debug.js:43634
saveChanges billRecordController.js:113
Ext.create.items.tbar.handler serviceToolView.js:206
Ext.define.fireHandler ext-all-debug.js:46226
Ext.define.onClick ext-all-debug.js:46216
(anonymous function)
wrap