1

这是我的操作execute()方法,

@Override
public String execute() throws Exception {
    
    ActionContext aContext = ActionContext.getContext();        
    aContext.getParameters().put("reqVar1", "reqVar1-Value");
    
    return SUCCESS;
}

我想在 JSP 中获取参数值,如下面的代码,

<s:property value="#parameters.reqVar1" />

但它不起作用。

我看到参数在堆栈上下文中:

在此处输入图像描述

如何在 JSP 中获取参数值?

4

1 回答 1

0

参数总是使用一个类型Map<String, String[]>。并且您需要正确放置参数,即

aContext.getParameters().put("reqVar1", new String[] {"reqVar1-Value"});

并正确获得,即

<s:property value="%{#parameters.reqVar1[0]}" />

更好的方法是使用包含在请求中的params拦截器 defaultStack来填充参数。

另见:

于 2013-07-26T08:16:15.760 回答