//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 这个页面,可是没有任何跳转,这是怎么回事?

解决方案 »

  1.   

    不太懂ext, LZ是不是发ajax请求?
      

  2.   

    success : function(form, action) {
                        Ext.Msg.alert(" 提示", "保存成功!");
                    },
                    failure : function(formm, action) {
                        Ext.Msg.alert(" 提示", "保存失败:");
                    }
    看到这个了,, 估计是ajax请求了!
    ajax请求你的视图应该用json/stream类型来返回, 页面跳转在你的success:function里面做.!
      

  3.   

    已解决,是因为在action里面,使用  out.println(true);
     已经将响应回来的东西已经返回了,请求已经结束。所以不会再在这里面直接跳转了。
      

  4.   

    弱弱的问下.LZ怎么解决的呢?通过Struts可以直接跳转到其他的页面吗?看代码也想是ajax的啊,
    看了很多这类的demo,都是在js中判断为成功后再进行跳转的啊...