Struts2 Study Notes (20): use tags to prevent repeated submission of forms

Source: Internet
Author: User

The <s: token/> label prevents repeated submission. The usage is as follows:

Step 1: Add <s: token/> to the form.

<S: Form Action = "helloworld_other" method = "Post" namespace = "/test">

<S: textfield name = "person. Name"/> <s: token/> <s: Submit/>

</S: Form>

Step 2:

 <  Action  Name  = "Helloworld _*"  Class  = "Com. Jim. Action. helloworldaction"  Method  = "{1 }"  > 

< Interceptor-ref Name = "Defaultstack" />

< Interceptor-ref Name = "Token" />

< Result Name = "Invalid. Token" > /WEB-INF/page/message. jsp</ Result >

< Result > /WEB-INF/page/result. jsp </ Result >

</ Action >

The above configuration is added with the "token" interceptor and "invalid. token result. Because the token interceptor returns "invalid" directly when the session token is inconsistent with the requested token. token.


In the debug status, the following information is displayed on the console because the Struts. Token and Struts. Token. Name attributes are not in the action. We do not need to care about this error:

Severe: parametersinterceptor-[setparameters]: Unexpected exception caught setting 'struts. token 'on 'class XXX: Error setting expression' struts. token 'with value' [ljava. lang. string; @ 39f16f'

Severe: parametersinterceptor-[setparameters]: Unexpected exception caught setting 'struts. Token. name'


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.