Вопрос

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