Parameters with no mutators and accessors (setters/getters) along with the parameters interceptor in Struts 2

前端 未结 3 1743
故里飘歌
故里飘歌 2020-12-19 06:31

In the following action class, I\'m using the parameters interceptor.

@Namespace(\"/admin_side\")
@ResultPath(\"/WEB-INF/content\")
@ParentPackage(value = \"         


        
3条回答
  •  遥遥无期
    2020-12-19 06:44

    I've already said in the comment that interceptor parameters are not inherited by the interceptor configs of the parent packages if you define your own set of parameters that override the default settings. See Interceptor Parameter Overriding Inheritance.

    There are also some techniques used to obtain two different maps of interceptor parameters, see Getting Interceptor Parameters in Struts2.

    The convention plugin creates XWork package configs that inherited from some parent package. See my answer for Struts 2 Convention Plugin Define Multiple Parent Packages.

    So, all you have to do is to override the default parameter set by the parent configuration if you want to add your own parameters to the set. Either interceptor tag or interceptor-stack tag and you should do it for each interceptor-ref tag.

    The convention plugin uses @InterceprorRef annotation for the same purpose but with a caveat that if applied on the class, it applies on each action of that class. So, be careful when using this annotation on the class level. You are overriding the interceptor stack parameters, so you should use a prefix followed by dot of the interceptor name referenced in the stack for each parameter name, but this only works if you have unique names of the interceptor-refs in the stack.

    If you have two references of the params interceptor in the paramsPrepareParamsStack then you can't override the second params interceptor-ref unless you create your own interceptor stack and specify parameter overrides on each reference of the interceptor.

提交回复
热议问题