我们公司因为项目需要想把界面弄成ExtJs的。我以前也没学过,临时弄了点例子,结果发现问题了,我用的是Struts2 Spring Hibernate Mysql
private boolean success;
private String message;
private String username;
private String password;
private String randCode;
private DefaultService ds;
public String execute() throws Exception{
if(username.equals("username")){
this.success = true;
this.message="你的账号是:"+username+"密码为:"+password;
}else{
this.success=false;
this.message="您输入的用户不能登陆系统";
}
return SUCCESS;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRandCode() {
return randCode;
}
public void setRandCode(String randCode) {
this.randCode = randCode;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public DefaultService getDs() {
return ds;
}
public void setDs(DefaultService ds) {
this.ds = ds;
}
login : function() {
this.fp.form.submit({
waitMsg : "正在登陆......",
url : "./Login.action",
success : function(form, action) {
window.location.href = "";
},
failure : function(form, action) {
form.reset();
if(action.failureType == "connect"){
Ext.Meg.alert("服务器指定的路径链接不上");
}
if (action.failureType == Ext.form.Action.SERVER_INVALID) {
Ext.MessageBox
.alert("警告", action.result.errors.msg);
}else{
Ext.MessageBox
.alert("登陆失败", action.result.message);
}
}
}
);
}
每次返回的failureType 只要注入了ds就返回 "connect" , 如果不注入就能正常传递。