Chau Than
Chau Than

Reputation: 150

How to set Alias Interceptor's parameter with annotations

I'm a newbie in Struts 2

I want to use Alias Interceptor with annotations.

@Action(value="profile", results={
  @Result(name=SUCCESS, location="/home.jsp")}, interceptorRefs={
      @InterceptorRef(value="alias", params={"aliases", "#{'username':'name'}"}),
      @InterceptorRef(value="basicStack")})

But I get always the error:

WARNING: Caught OgnlException while setting property 'aliases' on type 'com.opensymphony.xwork2.interceptor.AliasInterceptor'.

Upvotes: 1

Views: 417

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50281

As you can see in the Alias Interceptor documentation, the only accepted parameter is aliasesKey, used to change the name of the Action property containing your aliases Map (the default is aliases, and generally you don't need to change it).

You simply need to apply your aliases as Action parameter, instead of Interceptor parameter:

    @Action(value = "profile", 
           params = { "aliases", "#{'username':'name'}"},
          results = { @Result(name=SUCCESS, location="/home.jsp")}, 
  interceptorRefs = { @InterceptorRef(value="alias"),
                      @InterceptorRef(value="basicStack")})

Upvotes: 1

Related Questions