使用struts2注释定义拦截器 [英] define interceptors with struts2 annotations
问题描述
我正在尝试使用提供Java注释的struts2-convention-plugin来定义struts2组件.
到目前为止,使用Actions效果还不错,但是如何使用批注定义拦截器呢? (我说的是@InterceptorRefs
或@InterceptorRef
).
I'm trying to use the struts2-convention-plugin which provides java annotations to define struts2 components.
With Actions so far so good but how can i use annotations to define interceptors ? (i'm talking of @InterceptorRefs
or @InterceptorRef
).
这甚至有可能吗?目前,我已经使用struts.xml
文件配置了带有注释和拦截器的动作.
Is this even possible ? At the moment i've configured actions with annotations and interceptors with the struts.xml
file.
是否可以完全消除struts.xml
文件并使用100%面向注释的配置?
Is it possible to completely eliminate the struts.xml
file and use a 100% annotation oriented configuration ?
推荐答案
struts2-convention-plugin不替代XWork及其基于xml的配置.因此,如果您使用自定义拦截器,则无法消除对struts.xml
的需求.有关常规插件用法的参考和说明,请参见 docs .
The struts2-convention-plugin doesn't replace XWork and its configuration which is xml based. So you cannot eliminate a need of struts.xml
if you are using custom interceptors. For reference and explanation of the convention plugin usage see docs.
这篇关于使用struts2注释定义拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!