Project client, server-side validation, database federated UNIQUE constraint, transaction management.

Source: Internet
Author: User

There is a requirement in the project to publish an activity, record the ID and participant ID of participating in the activity, call the interface, add a record to the collection, and add a record to the transaction table. Finally, according to the results of the return, give different information.

1. If you are currently working on a JSP page, decide if you have participated. After you have participated, the join button is not a point. In case of no participation, the button can be clicked.

2.jsp client plus JS processing, after the button clicked, the button is not point.

3. In the controller, before the business logic begins, Java again determines if it has participated in the activity.

4. In the database, participate in the table (activity ID, participant ID) plus federated unique constraints. Handles non-recurring participation according to the exception.

5. Put the operations of the above tables into one transaction. Avoid situations where participants are repeatedly involved.

Summary: Do not trust the client's authentication, do not believe the network delay (multiple clicks to submit the situation ~~!!), under normal circumstances, the above 1 to 5 any situation can restrict participants to participate in only one activity, but the project on-line in practice, but there is still a record of repeated participation. So only by uniting the above situation together to deal with them.

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.