0

我有一个带有拦截器配置的默认包,我正在将该包扩展到另一个包并调用相同的拦截器

<action name="availability**">
            <param name="subTab">availability</param>
            <interceptor-ref name="tabStack"/>          
            <result>/WEB-INF/jsp/index.jsp?include=visibilit/availability.jsp</result>                      
        </action>

问题是我的拦截器代码中没有读取参数:

Map params = invocation.getInvocationContext().getParameters();
subTab = params.get("subTab").toString(); //NULL exception

知道如何将参数传递给扩展拦截器吗?

谢谢!

4

2 回答 2

0

The getParameters() method which you are calling only returns the parameters from the HTTP request. The parameters set in struts.xml with are called "static parameters", and you can access them (within the intercept() method) like this:

ActionConfig config = invocation.getProxy().getConfig();
Map<String, String> parameters = config.getParams();
String subTab = params.get("subTab");

Source: StaticParametersInterceptor.java

于 2010-06-18T12:59:38.743 回答
0

你能试试这个语法吗

<action name="availability**">
<interceptor-ref name="tabStack">
     <param name="subTab">availability</param>
</interceptor-ref>
</action>

我不确定,但也许这会起作用

于 2010-06-18T06:35:49.553 回答