`

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...

    Artificial Neural Networks_New Research-Nova Science(2017).pdf

    In the first part of the chapter an analysis of the main parameters which influence the ANN implementation in the examined papers was carried out, then some applications of ANN in energy and buildings...

    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 ...

    BlazeDS开发者指南

    Using a pair of Producer and Consumer components in an application 131 Message filtering 132 Configuring the Messaging Service 136 Chapter 10: Connecting to the Java Message Service (JMS) About JMS ...

    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/...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    If this is enabled, by calling the VsEnableImplicitPalette() function, the driver will define the settings for a given wavelength once, then saves the results within the VariSpec for faster access ...

    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 ...

    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 ...

    Python Cookbook英文版

    4.11 Reading INI Configuration Files 4.12 Sending Binary Data to Standard Output Under Windows 4.13 Using Random-Access Input/Output 4.14 Updating a Random-Access File 4.15 Splitting a Path ...

    微软内部资料-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...

    Apache-Solr-Reference-Guide-v3.5

    such as boosting and faceting, which can be used to fine-tune search results. : This section discusses performance tuning for Solr. It The Well-Configured Solr Instance begins with an overview of the ...

    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 ...

    mybatis-3.2.3

    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 ...

    Fuzzy Control Systems

    Chapter 5—Alternative Structures for Knowledge Representation in Fuzzy Logic Controllers 1 Introduction 2 Basic Structures of Fuzzy Logic Controller 3 Certainty Qualified Antecedents 4 ...

Global site tag (gtag.js) - Google Analytics