重定向操作中的Struts2动态参数名称 [英] Struts2 dynamic parameter name in redirect-action

查看:38
本文介绍了重定向操作中的Struts2动态参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的一个struts2映射文件成功地使用了重定向操作,如下所示:

I'm successfully using a redirect-action for one of my struts2 mapping files as follows:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
  <result name="success" type="redirect-action">
    <param name="actionName">myOtherAction</param>
    <param name="foo">${foo}</param>
  </result>
  <interceptor-ref name="defaultComponentStack"/>
</action>

这是我想要做的:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
  <result name="success" type="redirect-action">
    <param name="actionName">myOtherAction</param>
    <param name="${dynamicParameterName}">${dynamicParameterValue}</param>
  </result>
  <interceptor-ref name="defaultComponentStack"/>
</action>

换句话说,我希望传递的参数名称是动态的.有人知道这是否可能吗?

In other words, I want the name of the parameter that I'm passing to be dynamic. Does anyone know if this is possible?

推荐答案

实际上,这不起作用.但是,我能够做到以下几点:

Actually, that doesn't work. However, I was able to get this working doing the following:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
   <result name="success" type="redirect-action">
      <param name="actionName">myOtherAction</param>
      <param name="${dynamicParameterName}">${dynamicParameterValue}</param>
   </result>
</action>

我只是以为那是行不通的.

I had just assumed it wouldn't work.

这篇关于重定向操作中的Struts2动态参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆