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

本文介绍如何在SpringMVC应用中正确配置ExtJS以实现JSON数据的交互,包括解决HTTP 415、400、500错误的方法,详细解释了使用ExtJS组件库进行数据加载及请求设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;

}
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值