简体   繁体   English

如何在 Struts 2 中使用注解定义拦截器

[英]How to define interceptors using annotations in Struts 2

I'm trying to use the struts2-convention-plugin which provides Java annotations to define Struts2 components.我正在尝试使用提供 Java 注释的struts2-convention-plugin来定义 Struts2 组件。

With Action s so far so good but how can I use annotations to define interceptors ?到目前为止, Action非常好,但我如何使用注释来定义拦截器? (I'm talking of @InterceptorRefs or @InterceptorRef ). (我说的是@InterceptorRefs@InterceptorRef )。

Is this even possible ?这甚至可能吗? At the moment I've configured actions with annotations and interceptors in the struts.xml file.目前我已经在struts.xml文件中配置了带有注释和拦截器的操作。

Is it possible to completely eliminate the struts.xml file and use a 100% annotation oriented configuration ?是否可以完全消除struts.xml文件并使用 100% 面向注解的配置?

The struts2-convention-plugin doesn't replace XWork and its configuration which is xml based. struts2-convention-plugin不会替换 XWork 及其基于 xml 的配置。

So, you cannot eliminate a need of struts.xml if you are using custom interceptors.因此,如果您使用自定义拦截器,则无法消除对struts.xml的需求。 For reference and explanation of the convention plugin usage see docs.有关约定插件用法的参考和解释,请参阅文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM