Redirect Action Result

Redirect Action Result : This redirect pattern is supported by Struts 2. The ActionMapper provided by the ActionMapperFactory is used to redirect the browser to a URL that invokes the specified action. You can see a simple implementation of this in the following struts 2 application. 

Redirects Dynamic Parameters: The action-redirect result takes following parameters:

  • actionName
  • namespace
  • method
  • encode
  • parse
  • location
  • prependServletContext


parameters ------------

  • actionName (default) - the name of the action that will be redirect to

  • namespace - used to determine which namespace the action is in that we're redirecting to . If namespace is null, this defaults to the current namespace

     

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

    <package name="secure" extends="struts-default" namespace="/secure">
        
    <-- Redirect to an action in the same namespace -->
        
    <action name="dashboard" class="">
            
    <result>dashboard.jsp</result>
            
    <result name="error" type="redirect-action>error</result>
        </action>

        <action name="
    error" class="">
            
    <result>error.jsp</result>
        
    </action>
    </package>

    <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
       
    <-- Pass parameters (reportType, width and height) -->
       
    <!--
       The redirect-action url generated will be :
       /genReport/generateReport.action?reportType=pie&width=100&height=100
       
    -->
       
    <action name="gatherReportInfo" class="">
          
    <result name="showReportResult" type="redirect-action">
             
    <param name="actionName">generateReport</param>
             
    <param name="namespace">/genReport</param>
             
    <param name="reportType">pie</param>
             
    <param name="width">100</param>
             
    <param name="height">100</param>
          
    </result>
       
    </action>
    </package>
  • 例如
  • <param name="转发的action的成员名">${被转发的action中变量}</param>
       <param name="fileName">${fileName}</param>

    posted on 2009-04-26 22:59 luofeng225 阅读(437) 评论(0)  编辑  收藏 所属分类: Struts2


    只有注册用户登录后才能发表评论。


    网站导航:
     
    <2009年4月>
    2930311234
    567891011
    12131415161718
    19202122232425
    262728293012
    3456789

    导航

    统计

    公告

    我曾经听到这么一个故事: 一个年轻的程序员问一个老程序员(一个比较牛逼的公司的CTO) 年轻程序员: 你为什么这么牛X., 就好像没有你不会的。老程序员: 积累的。年轻程序员: 怎么才能积累到您的程度呢。我每天都在积累。但是似乎都没有感觉到进步。老程序员: 我从20岁开始做到了一件事情,直到今天,而且尽可能地保证不间断。年轻程序员: 到底是什么? 老程序员: 我每天保证自己有2个小时在学习新的东西。

    常用链接

    留言簿(3)

    随笔分类

    随笔档案

    文章分类

    相册

    收藏夹

    Java Website

    java技术博客

    搜索

    最新评论

    阅读排行榜

    评论排行榜