Struts2 interceptors and annotation

2k views Asked by At

Before I used struts.xml for configuration my struts2-application. But new my application I need to implement using annotations. For my action class I used such annotation

@Namespace("/public")
@InterceptorRefs(value = { @InterceptorRef(value = "authInterceptor"), @InterceptorRef(value = "defaultStack") })
@ResultPath(value = "/")
@Result(name = "error", location = "/test/error.jsp")

In struts.xml I set name for the interceptor class and then used it in interceptor-stack. So I see that for my Action class I can set the name of interceptor (value = "authInterceptor"), but where I can set this name for my interceptor class????? Or using annotations cann't implement configuration of interceptors?

1

There are 1 answers

0
Quaternion On

I've not seen configuration of interceptors done outside of xml. You'll find your annotation work a lot easier if you use the conventions plugin. By following some simple rules, you can avoid any xml or annotations by just following nameing conventions. Then only where you must deviate from those conventions will you find yourself using annotations.