Struts2 input validation (0): Input Validation Overview

Source: Internet
Author: User

Input ValidationThis is a problem that must be handled by all web applications. Because it is an open web application, all Web browsers on the network can use this application freely, therefore, the data collected by the application through the input page is very complex. It not only contains incorrect input from normal users, but may also contain malicious input from malicious users. A robust application system must block these illegal inputs from the application to prevent them from entering the system.

If the input is abnormal, the system is interrupted abnormally. If the input is heavy, the system crashes. The application must be able to normally process various data received by the presentation layer. The common practice is to directly return data when an exception occurs, prompting the browser to re-enter the data, that is, filter out the abnormal input. The filtering of abnormal input is the input verification, also known as data verification.

Input verification is divided into client verification and server verification.Client VerificationIt mainly filters out misoperations of normal users, mainly through JavaScript code;Server VerificationIt is the final line of defense for the entire application to block illegal data, mainly through programming in the application.

The main function of client verification is to prevent normal viewers from mistakenly inputting data and only preliminarily filter the input. Client verification is powerless for malicious user behaviors. Therefore, client verification cannot replace server verification. Of course, client verification is also indispensable because most web application viewers are normal, and their input may contain a large number of incorrect inputs. Client verification blocks these incorrect inputs on the client, this reduces the server load.

The struts2 framework provides powerful input verification functions, including server-side verification and client-side verification. Struts2 has two input verification methods:

① Use XML to compile the validation rule file.

② Rewrite the validate method.

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.