`

struts2中常用Result总结

阅读更多

1.dispatcher(默认) 

   dispatcher类型表示将请求转发给其他资源,浏览器显示的导向是action。Action中的数据一直保存在。
    只能是页面,不能是另一个action(可用type="chain"解决)

 <package name="register" namespace="/" extends="yunfile-deafult" >
        <action name="register" class="com.yingjun.action.RegisterAction" >
            <result name="success" >/success.jsp</result>
             <result name="input">/registerform.jsp</result>
           </action>
    </package>

 2.redirect

 

  redirect是重定向到其他资源(参数会丢失,地址栏会变化。可以防止用户刷新浏览器重复提交表单的信息),浏览器显示的导向是jsp。

<result type="redirect">/testSuccess.jsp</result> 

 3.chain

 

  用于把相关的几个action连接起来,共同完成一个功能。

<result type="redirect">register</result> 

 4.redirectAction(和redirect类型在使用上其实并没有什么区别,只是写法不同而已)

 

<package name="public" extends="struts-default">
    <action name="login" class="...">
        <!-- Redirect to another namespace -->
        <result type="redirectAction">
            <param name="actionName">dashboard</param>
            <param name="namespace">/secure</param>
        </result>
    </action>
</package>

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics