On Jan 24, 2008 1:04 PM, xianwinwin <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I wonder if it is possible to pass a parameter with a value to an
> interceptor.
>
> Example:
>
> I have the following interceptor:
>
> <interceptor name="authentication"
> class="com.struts.security.AuthenticationInterceptor"/>
>
> (parameterGivenInXmlFile==4)
>
>
> the implementation is:
>
> public String intercept (ActionInvocation invocation) throws Exception
> {
> ...
> if (parameterGivenInXmlFile ==3)
> //do something
> ....
> }
>
>
> thanks for any input
>
If you need the parameters on a per action basis, you can use:
<param name="parameterGivenInXmlFile">3</param>
inside the <action> tag in your struts.xml file. Then in your
interceptor you can access the parameter using:
invocation.getProxy().getConfig().getParams().get("parameterGivenInXmlFile");
I'm not sure if you can use the <param> tag inside the <interceptor>,
but that might be possible as well.
(*Chris*)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]