发现easyui form提交请求struts2后,不会回调easyui form的success函数,是不是bug?,而且点保存会弹出下载页面,
add.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<div id="user-window" title="用户注册" style="width:500px;height:350px;">
<div style="padding:20px 20px 40px 80px;">
<form method="post" action="login!saveOrUpdate.action" id="regform">
<table>
<tr>
<td>用户名:</td>
<td><input name="userId" style="width:200px;"></input></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="result" style="width:200px;"></input></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="password" style="width:200px;" type="password"></input></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input name="repassword" style="width:200px;" type="password"></input><br/>
<font color="#FF0000">请正确填写,否则不能取回密码</font>
</td>
</tr>
</table>
</form>
</div>
<div style="text-align:center;padding:5px;">
<input type="submit" value="提交" >
<a href="javascript:void(0)" onclick="saveUser()" id="btn-save" icon="icon-save">保存</a>
<a href="javascript:void(0)" onclick="closeWindow()" id="btn-cancel" icon="icon-cancel">取消</a>
</div>
</div>
<script>
$(function(){
$('#btn-save,#btn-cancel').linkbutton();
initWindow('user-window');
});
function saveUser(){
myFormSubmit('regform',callBack);
}
function callBack(){
grid.datagrid('reload');
}
$('#regform').form({
url:'login!saveOrUpdate.action',
success:function(data){
eval('data='+data);
$.messager.alert('Info', data, 'info');
}
});
function myFormSubmit(formId,callback){
var form =$('#'+formId);
form.url=form.attr('action');
form.form('submit', {
url:form.url,
onSubmit: function(){
alert(222);
return true;
},
success:function(data){
alert(data);
eval('data='+data);
if (data.success){
if(callback){
callback();
}
closeWindow();
} else {
$.messager.alert('错误',data.msg,'error');
}
}
});
}
</script>
action
public class AjaxLoginAction extends BaseAction {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
private JSONObject resultObj;
public JSONObject getResultObj() {
return resultObj;
}
public void setResultObj(JSONObject resultObj) {
this.resultObj = resultObj;
}
// 用户Ajax返回数据
private String result;
// struts的属性驱动模式,自动填充页面的属性到这里
private String loginName;
private String password;
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String saveOrUpdate(){
System.out.println(userId);
this.setJsonResult("true", "编辑除功");
System.out.print(this.getJsonResult());
return null;
}