Domanda

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'.

È stato utile?

Soluzione

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")})
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top