Struts2 token interceptor in annotation


I'm using struts 2.3.1 with token interceptor.How can i use token interceptor in annotation(convension) based Action Class.

here is My struts.xml

<action name="tokenAction" class="roseindia.action.TokenAction"> <interceptor-ref name="token" /> <interceptor-ref name="basicStack"/> <result name="success" >/success.jsp</result> <result name="invalid.token">/index.jsp</result>

can any one please tell annotation based for the same.


It looks to me like this is fairly clear in the documentation <a href="http://struts.apache.org/release/2.1.x/docs/convention-plugin.html#ConventionPlugin-InterceptorRefannotation" rel="nofollow">here</a>, you need to do this:

package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Actions; @InterceptorRefs({ @InterceptorRef("token"), @InterceptorRef("basicStack") }) @Results({ @Result(name="success", location="/success.jsp") @Result(name="invalid.token", location="/index.jsp") }) public class HelloWorld extends ActionSupport { @Action(interceptorRefs={ @InterceptorRef("token"), @InterceptorRef("basicStack") }) public String myActionMethod() { //do stuff return SUCCESS; } }


  • java, drive APIv2, appengine 1.7.3, struts2.3.4.1, OAuth2. TokenResponseException: 400 OK invalid_gr
  • Handling exception logging in a Java task scheduler program?
  • Monotouch crashes with NullReferenceException on non nullable object
  • Access object instance inside an event handler
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • How to get links to open in the native browser in iOS Meteor apps?
  • How to assign byte[] as a pointer in C#
  • TextToSpeech.setEngineByPackageName() triggers NullPointerException
  • revitapi ironpython ToRoom returns “indexer # object”
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • App restarts from wrong activity
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • How to use carriage return with multiple line?
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Using variable in a value field in jMeter
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • PHP - How to update data to MySQL when click a radio button
  • Is possible to count alias result on mysql
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Perl system calls when running as another user using sudo
  • what is the difference between the asp.net mvc application and asp.net web application
  • Upload files with Ajax and Jquery
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Apache 2.4 - remove | delete | uninstall
  • Numpy divide by zero. Why?
  • php design question - will a Helper help here?
  • Cannot Parse HTML Data Using Android / JSOUP
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Java static initializers and reflection
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?