ext+struts2问题,求高手解惑...
使用ext与struts2整合时,在extjs中接受struts2返回的数据时,始终是调用failure方法,小弟很不明白为什么,其他的没地方错....求大哥们帮忙看看...
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = "side";
var simple = new Ext.form.FormPanel({
labelWidth : 40,
labelAlign : 'left',
labelSeparator : ':',
baseCls : 'x-plain',
defaultType : 'textfield',
defaults : {
width : 180
},
items : [{
fieldLabel : '账号',
name : 'person.username',
allowBlank : false,
blankText : '账号不能为空'
}, {
inputType : 'password',
fieldLabel : '密码',
name : 'person.password',
allowBlank : false,
blankText : '密码不能为空'
}],
buttons : [{
text : '提交',
type : 'submit',
handler : function() {
if (simple.getForm().isValid()) {
Ext.Msg.show({
title : '请稍等',
msg : '正在加载...',
progressText : "",
width : 300,
progress : true,
closable : false,
animEl : "loding"
});
var f = function(v) {
return function() {
var i = v / 11;
Ext.Msg.updateProgress(i, '');
}
}
for (var i = 1; i < 13; i++) {
setTimeout(f(i), i * 150);
}
simple.getForm().submit({
url : 'login.action',
method : 'post',
success : function(form, action) {
Ext.Msg.alert("登陆成功",action.result.message);
},
failure : function(form, action) {
Ext.Msg.alert("登陆失败",action.result.message);
}
});
}
}, {
text : '重置',
handler : function() {
simple.form.reset();
}
}]
});
var _window = new Ext.Window({
title : '登录窗口',
layout : 'fit',
width : 280,
height : 150,
plain : true,
bodyStyle : 'padding:10px',
maximizable : false,
closeAction:'close',
closable:false,
collapsible:true,
buttonAlign:'center',
items:[simple]
});
_window.show();
})
这是js代码,下面的是后台action:
package com.haubo.ext.action;
import com.haubo.ext.domain.Person;
import com.opensymphony.xwork2.ActionSupport;
public class ExtjsAction extends ActionSupport {
private Boolean success;
private String message;
private Person person;
public Boolean isSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public String execute(){
if (person.getUsername().equals("admin")&&person.getPassword().equals("123")) {
this.success = true;
this.message = "您的账号是:"+person.getUsername()+"密码为:"+person.getPassword()+","+this.success;
} else {
this.success = false;
this.message = "对不起,您输入的账号或密码有误!";
}
return SUCCESS;
}
}
还有一个POJO:
package com.haubo.ext.domain;
public class Person {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
显示的页面在附件:登陆界面图片
当输入正确的用户名和密码时,弹出的提示框为:附件-->>提示框图片
本来应该显示的对话框的标题是:登陆成功
应该说清楚了吧....
希望大哥大姐们帮忙看一下,我真的很纳闷....
谢谢!!!
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = "side";
var simple = new Ext.form.FormPanel({
labelWidth : 40,
labelAlign : 'left',
labelSeparator : ':',
baseCls : 'x-plain',
defaultType : 'textfield',
defaults : {
width : 180
},
items : [{
fieldLabel : '账号',
name : 'person.username',
allowBlank : false,
blankText : '账号不能为空'
}, {
inputType : 'password',
fieldLabel : '密码',
name : 'person.password',
allowBlank : false,
blankText : '密码不能为空'
}],
buttons : [{
text : '提交',
type : 'submit',
handler : function() {
if (simple.getForm().isValid()) {
Ext.Msg.show({
title : '请稍等',
msg : '正在加载...',
progressText : "",
width : 300,
progress : true,
closable : false,
animEl : "loding"
});
var f = function(v) {
return function() {
var i = v / 11;
Ext.Msg.updateProgress(i, '');
}
}
for (var i = 1; i < 13; i++) {
setTimeout(f(i), i * 150);
}
simple.getForm().submit({
url : 'login.action',
method : 'post',
success : function(form, action) {
Ext.Msg.alert("登陆成功",action.result.message);
},
failure : function(form, action) {
Ext.Msg.alert("登陆失败",action.result.message);
}
});
}
}, {
text : '重置',
handler : function() {
simple.form.reset();
}
}]
});
var _window = new Ext.Window({
title : '登录窗口',
layout : 'fit',
width : 280,
height : 150,
plain : true,
bodyStyle : 'padding:10px',
maximizable : false,
closeAction:'close',
closable:false,
collapsible:true,
buttonAlign:'center',
items:[simple]
});
_window.show();
})
这是js代码,下面的是后台action:
package com.haubo.ext.action;
import com.haubo.ext.domain.Person;
import com.opensymphony.xwork2.ActionSupport;
public class ExtjsAction extends ActionSupport {
private Boolean success;
private String message;
private Person person;
public Boolean isSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public String execute(){
if (person.getUsername().equals("admin")&&person.getPassword().equals("123")) {
this.success = true;
this.message = "您的账号是:"+person.getUsername()+"密码为:"+person.getPassword()+","+this.success;
} else {
this.success = false;
this.message = "对不起,您输入的账号或密码有误!";
}
return SUCCESS;
}
}
还有一个POJO:
package com.haubo.ext.domain;
public class Person {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
显示的页面在附件:登陆界面图片
当输入正确的用户名和密码时,弹出的提示框为:附件-->>提示框图片
本来应该显示的对话框的标题是:登陆成功
应该说清楚了吧....
希望大哥大姐们帮忙看一下,我真的很纳闷....
谢谢!!!