Understanding and using the Session Token mechanism of Struts2

Source: Internet
Author: User

Understanding and using the Session Token mechanism of Struts2

I. Case study: there is actually nothing to mention about the problem of repeated form submission. This function can be said to be very weak, and is rarely used in current projects. It is of little practical significance, the reason for this is to introduce the interceptor and pave the way for the next chapter to learn the interceptor. When you look at the miscellaneous, you can just take a few minutes.

Ii. Case study: the token mechanism is similar to the Verification code implementation method. When a page request is scanned The tag processing class will be called during the convenience, and the tag processing class will generate a random number and return it to the page. In addition, copying a copy on the server prevents the session from being sent. When the request arrives at the server, the two strings are compared. If they are equal, they are passed. If they are not equal, the error page is displayed if they are submitted repeatedly. The biggest difference with the verification code is that repeated submission means that after the first successful submission, if you refresh the page after successful or press the return button of the browser to submit the page again without refreshing the current page, the token repeated submission mechanism will be triggered, and the page will jump to the repeated submission failure page.

A) add Label.

B) Configure

/Submission failure page. jsp

Name is the official rule of struts2. Do not make any mistakes.

C) add an interceptor to step B's action.

The order cannot be wrong.

It means that the token mechanism occurs before the Data assignment, type conversion, and other interceptors. This prevents repeated data submission.

Iii. Experience:

A) The learning framework should always read the source code. The source code is the painstaking efforts of the predecessors. Both the encoding format and the encoding quality are quite high. You don't need to read this precious learning material, what else do you think.

B) There are many methods to prevent repeated form submission, such as redirection in the previous chapter. However, there are many ways to prevent repeated submission of forms in projects. What I love most is to invalidate the submit button. When you click the submit button, we use js to invalidate the button directly, so that no one will be confused.

C) writing a program is the same as playing a game, so never get the best. We must always firmly believe that language is omnipotent. So sometimes, if one method fails, the problem will be solved. For example, I want to redirect 23hhr.com to www.23hhr.com for 301 today. After a whole morning, all kinds of articles on the Internet have been cracked, and all kinds of methods have been tried. The result is no good. Configuration of. htaccess is the most widely used on the Internet. I use apache to send tomcat to the proxy. how to configure apache does not access. htaccess. In the end, I Just configured it in vhost. cfg. So sometimes, we need to be good at hands-on experiments, so we can't think of anything.

4. Reference project: the token mechanism is too simple to provide project reference, so it is OK to configure according to analysis.

5. happy every day:

I have been chasing the goddess for a long time. Today I finally succeeded. The goddess asked me how I felt,

I said I felt a little unbelievable. She said, don't believe it, you pinch your face, I did it, and then I woke up ......

The right to final interpretation belongs to partner aishang. Please indicate the source for reprinting.

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.