Home StrutsMVCDemo6 - Struts2中的重定向(2.2.3)
Post
Cancel

StrutsMVCDemo6 - Struts2中的重定向(2.2.3)

PersonAction.java

1
2
3
public String execute() {
     return "p1_p2";
}  

struts.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- 公共配置包 -->
<package name="default" namespace="" extends="struts-default">
    <interceptors>
        <interceptor name="myLog" class="com.bbs.interceptor.LogInterceptor"/>
        <interceptor-stack name="myStack">
            <!-- 19个拦截器 其中一个是自定义的 -->
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <interceptor-ref name="myLog"></interceptor-ref>
        </interceptor-stack>
    </interceptors>      
    <default-interceptor-ref name="myStack"></default-interceptor-ref>
        
    <!-- 重定向 -->
    <global-results>
        <result name="index" type="redirect">/index.jsp</result>
        <result name="p1_p2" type="redirectAction">p2</result>
    </global-results>
</package>  

运行结果

This post is licensed under CC BY 4.0 by the author.