`

Parameters in configuration results

阅读更多
  1. Parameters in configuration results   
  2.  Edit Page    Browse Space    Add Page    Add News    
  3. Added by Dariusz Wojtas, last edited by Dariusz Wojtas on Feb 03, 2007  (view change)    
  4. Sometimes there is a need to redirect from one action to another, but you do not know the exact url or the destination url requires parameters that are only known in runtime.    
  5.   
  6. Struts 2 gives you easy to use solution for that problem.   
  7.   
  8. Parameters in action result definitions   
  9. <struts>  
  10. ....   
  11.    <package name="somePackage" namespace="/myNamespace" extends="struts-default">  
  12.       <action name="myAction" class="com.project.MyAction">  
  13.          <result name="success" type="redirect-action">otherAction?id=${id}result>  
  14.          <result name="back" type="redirect">${redirectURL}result>  
  15.       action>  
  16.   
  17.       <action name="otherAction" class="com.project.MyOtherAction">  
  18.          ...   
  19.       action>         
  20.    package>  
  21. ....   
  22. struts>  
  23. The only requirement is to declare the necessary properties in your action, in this case com.project.MyAction should define properties id and redirectURL with standard accessor methods.   
  24.   
  25. public class MyAction extends ActionSupport {   
  26.    private int id;   
  27.    private String redirectURL;   
  28.    ...   
  29.   
  30.   
  31.    public String execute() {   
  32.        ...   
  33.       if (someCondition) {   
  34.          this.redirectURL = "/the/target/page.action";   
  35.          return "back";   
  36.       }   
  37.   
  38.       this.id = 123;   
  39.       return SUCCESS;    
  40.    }   
  41.   
  42.    public int getId() { return this.id; }   
  43.    public void setId(int id) { this.id = id; }   
  44.    public String getRedirectURL() { return this.redirectURL; }   
  45.    public void setRedirectURL(String redirectURL) { this.redirectURL= redirectURL; }   
  46.    ...   
  47. }   
  48. In the above code if it returns SUCCESS then the browser will be forwarded to   
  49. /<app-prefix>/myNamespace/otherAction.action?id=123  
  50.   
分享到:
评论

相关推荐

    BURNINTEST--硬件检测工具

    - Workaround for the rare crash bug in Vista in atklumdisp.dll at address 0x730676ae. - Added trace debug information for BurnInTest startup and the 3D test. Release 5.3 build 1022 WIN32 release 12...

    mybatis-3.4.2.pdf

    parameters and retrieval of results. My Batis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records. 1.1.2 ...

    绕线转子异步电动机双馈调速系统及其仿真

    Through simulation results, various strategies and schemes can be compared, optimized, and their relevant parameters determined. In the field of asynchronous motor control, the vector control ...

    现代数字通信论文1

    By systematically varying these parameters and evaluating the performance on the Corel image dataset, the authors identify an optimal configuration that yields the best classification results. ...

    dbeaver v6.0.2

    - SQL errors now shown in results panel instead of modal dialog (configurable) - Certain long strings visibility problem was fixed - Auto completion was fixed for CALL/EXEC keywords - Tables/...

    11g_plsql_user_guide_and_reference.pdf

    However, in 11g Release 2, result caches are now shared across all instances in a RAC configuration. This change improves the scalability and availability of applications running in a RAC environment...

    WLR_SystemsBro_E.pdf

    - Compliance with many JEDEC standard test methodologies ensures that the WLR systems adhere to industry standards, enhancing confidence in the results obtained. 5. **Rapid Test Routine Creation** ...

    SQL Assistant v5.0

    You can now customize list of keywords that you also use as object and column names, and which you don't want SQL Assistant to treat as keywords, for example, the default configuration includes ID and...

    mysql-8-cookbook2018

    MySQL and basic configuration parameters. Chapter 5, Transactions, explains the four isolation levels of RDBMS and how to use MySQL for transactions. Chapter 6, Binary Logging, demonstrates how to ...

    Writing GNOME Applications

    Exploring the Results A Note about Version Numbers Adding GNOME GNOME Macros gnome-config GNOME Makefile Variables autogen.sh Some Grumpy GNOME Examples 10. Graphics Graphics in the X Window System ...

    CCD_descript

    The configuration of a CCD is illustrated in Figure 1-1. It consists of an electrode deposited on a dielectric film, which is formed on a semiconductor substrate. **1.1.1 CCD Structure** When a ...

    vim数据库插件dbext_420

    3.1 Displaying Results |dbext-configure-results| 3.2 Script Variables |dbext-configure-variables| 3.3 Database Specific Options |dbext-configure-options| 3.4 DB2 Modes |dbext-configure-db2| 4. ...

    Cisco Press - OSPF Network Design Solutions, 2nd Edition

    Using Tunable OSPF Parameters 202 Naming an Area 204 Standard Area Design 205 Golden Rules of Standard Area Design 205 Backbone Area Design 205 Backbone Design Golden Rules 206 Stub Area Design 207 ...

    微软内部资料-SQL性能优化2

    A stack is an area of memory in which program procedure or function call addresses and parameters are temporarily stored. In Process To run in the same address space. In-process servers are loaded ...

    hin2n_v0.6.0-rc2_allarch_20190704_by_hyz.apk

    2018-09-29: v.2.3.0_r71, Add -c parameters in supernode 2018-09-28: v.2.3.0_r71, Generate "master" version, freeze 2018-08-16: v.2.3.0_r54, Edge and supernode can reads a configuration file now ...

    Servlet查询数据库案例--Query(java源码)

    * initialization parameters (which come from the web.xml configuration file) * to create a single JDBC database connection, which is shared by all clients * of the servlet. ***/ public class Query...

    mybatis-3.5.10.zip

    MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map ...

    MyBatis3 User Guide

    MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map ...

    cirris operation manual

    In addition to the standard items, depending on the configuration and options selected, you may also receive: - Advanced adapters - Specialized test fixtures - Additional software licenses #### ...

Global site tag (gtag.js) - Google Analytics