如何在 Struts 2 中使用注解定义拦截器 [英] How to define interceptors using annotations in Struts 2

查看:45
本文介绍了如何在 Struts 2 中使用注解定义拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 struts2-convention-plugin,它提供 Java 注释来定义 Struts2 组件.

I'm trying to use the struts2-convention-plugin which provides Java annotations to define Struts2 components.

Action 到目前为止还不错,但我如何使用注释来定义拦截器?(我指的是 @InterceptorRefs@InterceptorRef).

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 in 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 的配置.

The struts2-convention-plugin doesn't replace XWork and its configuration which is xml based.

因此,如果您使用自定义拦截器,则无法消除对 struts.xml 的需求.有关约定插件用法的参考和说明,请参阅文档.

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.

这篇关于如何在 Struts 2 中使用注解定义拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆