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;
}
}
顯示的頁面在附件:登陸界面圖片
當輸入正確的用戶名和密碼時,彈出的提示框為:附件-->>提示框圖片
本來應該顯示的對話框的標題是:登陸成功
應該說清楚了吧....
希望大哥大姐們幫忙看一下,我真的很納悶....
謝謝!!!