`
yaozuodaoforfly
  • 浏览: 119036 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

StrutsResultSupport

 
阅读更多

A base class for all Struts action execution results. The "location" param is the default parameter, meaning the most common usage of this result would be:

This class provides two common parameters for any subclass:

  • location - the location to go to after execution (could be a jsp page or another action). It can be parsed as per the rules definied in the translateVariablesmethod
  • parse - true by default. If set to false, the location param will not be parsed for expressions
  • encode - false by default. If set to false, the location param will not be url encoded. This only have effect when parse is true

NOTE: The encode param will only have effect when parse is true

 

In the struts.xml configuration file, these would be included as:

 

  <result name="success" type="redirect">
      <param name="location">foo.jsp</param>
  </result>

or

 

  <result name="success" type="redirect" >
      <param name="location">foo.jsp?url=${myUrl}</param>
      <param name="parse">true</param>
      <param name="encode">true</param>
  </result>

In the above case, myUrl will be parsed against Ognl Value Stack and then URL encoded.

or when using the default parameter feature

 

  <result name="success" type="redirect">foo.jsp</result>

You should subclass this class if you're interested in adding more parameters or functionality to your Result. If you do subclass this class you will need to override doExecute(String, ActionInvocation).

 

Any custom result can be defined in struts.xml as:

 

  <result-types>
      ...
      <result-type name="myresult" class="com.foo.MyResult" />
  </result-types>

Please see the Result class for more info on Results in general.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics