Struts2 - 通过带有动态参数的注释转发 [英] Struts2 - forward by annotation with dynamic parameter
问题描述
我正在尝试使用动态参数将操作结果转发到另一个操作.传递给第二个操作的参数具有 ""
值.
I'm trying to forward action result to another action with dynamic parameter. The passed parameter to second action has ""
value.
@Result(name = "success",
location = "edit_service_subscribers",
type = "redirect",
params = {"selectedServiceId", "%{serviceId}"}
)
我在第一个动作中使用 getter 和 setter 声明了 private String serviceId;
,和 private String selectedServiceId;
在第二个动作中使用 getter 和 setter.
I declared private String serviceId;
with getter and setter in first action,
and private String selectedServiceId;
with getter and setter in second action.
问题在于填充参数的值.但是在哪里?
Problem is with filling the value of parameter. But where?
如何将动作类中全局变量的值传递给重定向参数?
How can I pass value of global variable in action class to redirected parameter?
推荐答案
使用
RedirectAction代码>
重定向到另一个操作.重定向
结果用于重定向到非操作 URL(例如外部网址).
use
RedirectAction
to redirect to another Action.Redirect
result is used to redirect to non-action URLs (like external URLs).
这不是OGNL:代替
"%{serviceId}"
使用
"${serviceId}"
这篇关于Struts2 - 通过带有动态参数的注释转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!