我已经在struts.xml中设置了全局的跳转
<package name="defaults" extends="struts-default">
<global-results>
<result name="success">/inc/success.jsp</result>
<result name="error">/inc/exception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.NullPointerException" result="error" />
<exception-mapping exception="java.lang.Exception" result="error" />
</global-exception-mappings>
</package>
局部的跳转是用的
struts2注解(Annotation)配置方式
类中有写到:
catch (Exception e) {
e.printStackTrace();
return ERROR;}
但是系统提示找不到跳转,请各位帮忙!
<package name="defaults" extends="struts-default">
<global-results>
<result name="success">/inc/success.jsp</result>
<result name="error">/inc/exception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.NullPointerException" result="error" />
<exception-mapping exception="java.lang.Exception" result="error" />
</global-exception-mappings>
</package>
局部的跳转是用的
struts2注解(Annotation)配置方式
类中有写到:
catch (Exception e) {
e.printStackTrace();
return ERROR;}
但是系统提示找不到跳转,请各位帮忙!
type=redirect
type=forward
public String execute() throws Exception{
}
这个是需要的
已经定义了全局异常,就直接在execute方法抛出异常就行了,不用捕获。也不用返回error