<package name="global-package" extends="struts-default" namespace="">
<interceptors>
<interceptor name="loginInterceptor" class="loginIntercepter"></interceptor>
<interceptor-stack name="loginDefaultStack">
<interceptor-ref name="loginInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginDefaultStack"></default-interceptor-ref>
<global-results>
<result name="logon" type="redirect">${url}</result>
<result name="quickservice" >/WEB-INF/jspV2/mmobile/quickService/LoginLoding.jsp</result>
<result name="logon2">**</result>
<result name="exception" type="chain">
<param name="actionName" >exceptionProcess</param>
<param name="method">process</param>
</result>
</global-results>
<全局异常>
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception" ></exception-mapping>
</global-exception-mappings>
<package name="json-package" extends="json-default" namespace="">
<interceptors>
<interceptor name="loginInterceptor" class="loginIntercepter"></interceptor>
<interceptor-stack name="loginDefaultStack">
<interceptor-ref name="loginInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginDefaultStack"></default-interceptor-ref>
<global-results>
<result name="logon" type="redirect">${url}</result>
<result name="quickservice" >/WEB-INF/jspV2/mmobile/quickService/LoginLoding.jsp</result>
<result name="logon2">**</result>
<result name="exception" type="chain">
<param name="actionName" >exceptionProcess</param>
<param name="method">process</param>
</result>
</global-results>
<全局异常>
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception" ></exception-mapping>
</package>
</package>
本文详细介绍了Struts框架中包、拦截器、结果映射及异常处理的配置方法。通过两个具体的包配置示例(global-package 和 json-package),展示了如何设置登录拦截器、默认拦截器堆栈、全局结果映射及异常映射。
1425

被折叠的 条评论
为什么被折叠?



