日期:2014-05-19 浏览次数:20920 次
//action方法里面就写了这么几句话
public String execute(){
System.out.println("empNo = "+this.getEmpNo());
try{
HttpServletResponse response = ServletActionContext.getResponse();
PrintWriter out = response.getWriter();
out.println("{success:true}");
// out.println(true);
out.flush();
out.close();
}catch(Exception ex){
ex.printStackTrace();
}
return SUCCESS;
}
//struts.xml里面的配置只配置另一个action
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2" extends="struts-default" namespace="/">
<action name="addEmployee" class="com.cocobra.action.EmployeeAddAction">
<result>/showEmployee.jsp</result>
</action>
</package>
</struts>
//js里面的请求
function submit() {
Ext.getCmp("empForm").getForm().submit({
waitMsg : "正在提交数据……",
waitTitle : "提示",
url : "addEmployee.action",
method : "POST",
success : function(form, action) {
Ext.Msg.alert(" 提示", "保存成功!");
},
failure : function(formm, action) {
Ext.Msg.alert(" 提示", "保存失败:");
}
});
}
//在提交数据,保存成功之后,想让它跳转到showEmployee.jsp 这个页面,可是没有任何跳转,这是怎么回事?