87,997
社区成员




总是给我返回一个Ext.Error: You're trying to decode an invalid JSON String: 的错误。原因在那里我查了半天也不知道在哪儿,从网上看,似乎都是我这样的写法,求帮助。
Ext.define('SJXC.view.Login', {
extend : 'Ext.window.Window',
alias : 'widget.loginForm', // 别名
requires : ['Ext.form.*', 'SJXC.view.CheckCode'],
initComponent : function() {
var form = Ext.widget('form', {
border : false,
bodyPadding : 10,
fieldDefaults : {
labelAlign : 'left',
labelWidth : 55,
labelStyle : 'font-weight : bold'
},
defaults : {
margins : '0 0 10 0'
},
items : [{
xtype : 'textfield',
fieldLabel : '帐号',
blankText : '帐号不能为空',
name : 'user.account',
id : 'user.account',
allowBlank : false,
width : 240
}, {
xtype : 'textfield',
fieldLabel : '密码',
blankText : '密码不能为空',
allowBlank : false,
id : 'user.password',
name : 'user.password',
width : 240,
inputType : 'password'
}],
buttons : [{
text : '登录',
handler : function() {
if (form.isValid()) {
form.submit({
clientValidation : true,
waitMsg : '请稍后',
//waitTitle : '正在验证登录...',
url : 'user_login.action',
success : function(form, action) {
//Ext.Msg.alert("",action.result.msg);
},
failure : function(form, action) {
Ext.Msg.alert("ERROR",action.result.msg);
}
});
}
}
}]
});
Ext.apply(this,{
height: 160,
width: 280,
title: '用户登陆',
closeAction: 'hide',
closable : false,
iconCls: 'login',
layout: 'fit',
modal : true,
plain : true,
resizable: false,
items:form
});
this.callParent(arguments);
}
});
action中我是这样写的:
public String login() throws Exception{
User loginUser = userService.findByNameAndByPassword(user.getAccount(), user.getPassword());
if(loginUser == null){
System.out.println("用户不存在");
response.getWriter().write("{success:false, msg:'用户不存在'}");
return "loginUI";
} else {
ActionContext.getContext().put("user", user);
return "success";
}
}