我在Struts 2项目中,简单的实现了一个异常类,然后再Action中抛出它,在struts.xml中这样配
<global-results>
         <result name="login" type="redirect">/account/login</result>
         <result name="exception">/error.jsp</result>
    </global-results>
    <global-exception-mappings>
         <exception-mapping result="exception" exception="java.lang.Exception"/>
         <exception-mapping result="exception" exception="com.zuwoba.exception.ProjectException"></exception-mapping>
    </global-exception-mappings>
但是却无法跳转到error.jsp页面,这是怎么回事?

解决方案 »

  1.   

    你return一个error,再把exception改成error
      

  2.   

    result name="exception"是这里面的exception
      

  3.   

    第一,你的global-results外层是否指定了包空间,即package标签。
    第二,name="exception",exception换一个名称,如myexception试一试。也有可能是struts2 的关键字。查看一下日志,看是否有异常。或跳到哪个页面。都说一下。
      

  4.   

    已经找出原因了,我在测试的时候是在Action中手动抛出异常的,但是我throw后,自己又catch了,所以Struts 2就捕捉不到异常了