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

有帮助吗?

解决方案

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")})
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top