下面是我的代码的一部分:strurs全局error配置: <package name="default" extends="struts-default">
<global-results>
<result name="error">/jsp/common/error.jsp</result>
<result name="invalid.token">/jsp/common/error.jsp</result>
<result name="exception">/jsp/common/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception" />
</global-exception-mappings>
</package>
Action public String list() throws Exception {
try {
//Integer.parseInt("aa");//故意制造错误,从而转入error页面
//addActionError("bb");//添加addActionError,以期跳转到Input页
map.clear();
map = DBHelper.getDefaultRequestMap4Page();//得到pageSize和Current的Map
this.setGroups(dao.list(map));//用dao方法得到list列表
} catch (Exception e) {
log.error(this.getClass().getName() + "!list 读取数据错误:" + ToolsUtil.getStackTrace(e));
throw new Exception(this.getClass().getName() + "!list 读取数据错误:" + ToolsUtil.getStackTraceHTML(e));
}
return SUCCESS;
}但是我一把
addActionError("bb");
这句的注释去掉,程序就变成了死循环................请问这是为何?????????????

解决方案 »

  1.   

    1)addActionError("bb"); 向Struts2的错误列表中加入一条记录;
    2)Struts2发现错误列表中信息非空,故而跳转至input页面(即调用list()方法的页面)
    3)不幸的是,该input页面会再次调用addActionError("bb");所以你又回到了1)PS:以上为猜测,或者说过去看过,但记不清了,或者是以为自己看过,但记不清了
      

  2.   

    或许你可以添加
    <global-results>
                 <result name="input">/jsp/common/input.jsp</result>
                <result name="error">/jsp/common/error.jsp</result>
                <result name="invalid.token">/jsp/common/error.jsp</result>
                <result name="exception">/jsp/common/error.jsp</result>
    </global-results>
    来验证我的想法,谢谢!
    (input.jsp请不要调用其它方法)
      

  3.   

    回1楼的:
    报出的错误是堆栈错误,我去查了一下...是apache陷入死循环才会报的错误回2楼的:
    <result name="input">/jsp/common/input.jsp </result>我一早就加过的,就是因为出了死循环,所以我去掉了.....
      

  4.   

    额...我查到起因了....是我在error里面执行了一个action<s:action name="top" namespace="/common" executeResult="true"></s:action>引入一个公用的top页面=========================
    但是这个公用页面里面没有addActionError这语句啊....还是不知道原因...额....