How to use token in struts

Source: Internet
Author: User

Many times to prevent repeated submissions, such as the forum in the issue of questions, if not control that can be submitted ~

How to use: Forum for example

Ask.do: Action for jumping to the question page

Ask.jsp: For the question page

Askok.do: A successful action submitted for questioning

ASKOK.JSP: The JSP that handles the jump after questioning

First of all ask this action to join Savetoken (request), which is to create a hidden form on the question page that is the ask.jsp page

<input type= "hidden" name= "Org.apache.struts.taglib.html.TOKEN" value= "a6b9ff6834284444001b8206723b654d" >

On Ask. The JSP page does the following: Use form for

Form 1.1 does not write name without this attribute but in Struts-config. The XML is configured with this actionform we can define it as question and configure Askok this action to write the corresponding form

<action path= "/askok" type= "..." name= "question" > must write this or you will report a failure to find the form.

If you want to be in ask. JSP this page to do JS processing to use the form name words can be directly written question because struts automatically generated the form after the name generated: <form name= "bangquestion" method= "POST" action= "/askok.do" >

Ask.jsp This page automatically generates add form name

Then write the IF (Istokenvalid (Ac.getrequest (), true) in Askok.do {

Add a question

}else

{

jump prompt

}

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: info-contact@alibabacloud.com 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.