Extjs3 SpringMVC使用 @RequestBody 标签问题记录

springMVC使用 @RequestBody(required = false) UserVO userInfo
传递json对象数据,往往会出现http 415,400,500等错误,总结一下需要使用ajax提交json数据才行,ajax提交使用proxy,参数为jsonData,不能为params;另外,需要设置Content-type属性为json,代码如下:
(由于使用了父类aaa,代码不全,但是主要的代码都在)
LogGridPanel = Ext.extend(aaa.grid.GridPanel,{
       
    myRecord : null,
    myStore : null,
    logColumnModel : null,
    sm : null,
    myParams : {"start":"0","pageSize":"25"},
   
    constructor : function(){
   
    this.myRecord = new Ext.data.Record.create([{
         name : "id",
         mapping:"ID"
      
    },{
         name : "account",
         mapping:"account"
   
    },{
        name : "registerTimeFrom",
        mapping : "registerTimeFrom"
    },{
    name : "registerTimeTo",
    mapping : "registerTimeTo"
    },{
    name : "provinceId",
    mapping : "provinceId"
    },{
        name : "cityID",
        mapping : "cityID"
    },{
        name :"countyId",
        mapping : "countyId"
   
    },{
        name : "classId",
        mapping : "classId"
    },{
        name : "status",
        mapping : "status"
    }]);
   
    this.myStore = new aaaGridStore({    
         record : this.myRecord,        
         proxy: new Ext.data.HttpProxy({
            url:'u/queryUserList.do',
            type:'ajax',
            scope:this,
            method: 'POST',            
            jsonData:this.myParams,
         headers: {'Content-Type':'application/json;charset=UTF-8'},    
        
            })
         ,
        root: 'result',       
    });
    this.myStore.load({
         params : {
              start : 0,
              pageSize : 10
            
             
         }
    
     });   
    this.sm = new Ext.grid.CheckboxSelectionModel();
   
    this.logColumnModel = new Ext.grid.ColumnModel([
      new Ext.grid.RowNumberer(),
      this.sm,
      {header : '账号', width : 160, dataIndex : "account"},
      {header : '注册日期', width : 160, dataIndex : "registerTime"},
      {header : '所在地',width : 160,dataIndex : 'szd'}
        
    ]);
   
    LogGridPanel.superclass.constructor.call(this,{
          region : "center",
          cm : this.logColumnModel,
          store : this.myStore,
                  stripeRows : true,
                  height : 530,
                  loadMask : {
                       msg : '数据加载中,请稍后...'
                    },
                  tbar : [{
                        text : "查看",
                        iconCls : 'query',
                        handler : this.clearSyslog,
                        scope : this
                 
                  },{
                      text : "停用",
                      iconCls : 'delete',
                      handler : this.clearSyslog,
                      scope : this
               
                },{
                    text : "启用",
                    iconCls : 'renewal',
                    handler : this.clearSyslog,
                    scope : this
             
              }],
                 
         bbar : new Ext.PagingToolbar({
                           pageSize : 10,
                           store : this.myStore,
                           displayInfo : true,
                           displayMsg : '当前显示{0}条到{1}条记录,一共有{2}条记录',
                           emptyMsg : "没有记录"
                    })
   
    });
    this.myStore.on('beforeload',this.setPagingCondition,this);
   
   
    },
    setPagingCondition:function(store){
        store.proxy.conn.jsonData = this.myParams;
       
    }
});

你可能感兴趣的:(Extjs3 SpringMVC使用 @RequestBody 标签问题记录)