I am using a submit button to save data and to avoid double submission i am using token interceptor.
I am using Struts annotation instead of XML configuration.
Without token my form is working well and on submit it is saving data, but when i use token interceptor then data is not saved.
Can anyone please help me out.
My syntax for Action is:
@Action (value = "/addNewHolidaySave",results =
{ @Result(name = "success", location = "addHoliday.tiles", type = "tiles"),
@Result(name = "invalid.token", type = "tiles", location = "invalidToken.tiles") },
interceptorRefs={
@InterceptorRef("token"),
@InterceptorRef("basicStack")
})
If you want to avoid double submission you should place
s:tokentag in the body of the form. While rendering it will generate two input fields with data needed to proceed your form submision withtokeninterceptor applied.You might also find these answers useful to you: Is it possible to set a struts token with a GUID as a token name and How Token Interceptor work in Struts 2.