API development often encountered some validation of the request data, at this time if the use of annotations there are two benefits, one is the validation logic and business logic separation, code clear, and the second is the validation logic can be easily reused, just need to verify the place to add annotations.Java
1. Validate () VerificationWrites the contents of the page form validation to the Validate () method, enabling the separation of validation and business processing contentAdd the Validate () method to the actionpublic void Validate () {if (//****) {Addfielderror ("name", "XX cannot xxx ....") "); If the conditions do not match, you can use the Addfielderror () method to add to the Actioncontext.}}Display er
when you enter data into Excel, you sometimes encounter a lot of duplicate data, for example, there is a worksheet, the first column shows the task name, the second column shows the task performer, and the third column shows the performer's gender, in which the task executor is performed alternately for a fixed number of people, and the gender is clearly either male or female and repetitive. If you encounte
Use PHP's own filter function for data validation
PHP filters contain two types ofValidation:Used to verify that a validation entry is validsanitization:Used to format the validated item, so it may modify the value of the validation entry, remove the illegal character, and so on.refer to the official PHP docum
Typically, the data to be written is validated before it is written to the database, avoiding more serious security issues (such as a generic SQL injection attack).
Mayfish can flexibly customize the validation rules for the content of the data to be written to reduce the hassle of developers manually verifying data fo
In the development of the application system interface, often need to do a lot of complex data validation, when the data entered in accordance with the provisions can be submitted to save.JQuery MINIUI provides a perfect way to verify and display the form data incorrectly.A common form control that has a
Validation of form data:Front desk verification: mainly through the JS verification, the expression of data is legitimate!Background verification: Through the background Java code to verify!Struts also provides a way to data validation!Struts data is tested and completed by
In-depth analysis of JavaWeb Item46 -- Struts2 data validation and Internationalization1. user input data validation1. Verification Method
A:Client Verification. (The Anti-gentleman cannot defend against the villain) Write js scripts on the page. The benefits of doing so are:Prompt when input is incorrect; reduce the pressure on the server
B,Server Verification.D
with information about the specific purpose of the Property.For example:[DataType (datatype.password)] public string Get set; }The display results are as follows: This property can be used to specify multi-select buttons, radio buttons, password entry boxes, and so on for the type of Data. 6, UIHintThe UIHint feature provides a template name to the asp. net MVC runtime, in case the template helper methods such as (displayfor and Editorfor) render
Http://www.studyofnet.com/news/339.htmlHttp://www.cnblogs.com/kissdodog/archive/2013/05/04/3060278.htmlThis article is guided by: the model in ASP. MVC3 is self-validating, which is passed. The NET4 System.ComponentModel.DataAnnotations namespace is completed. All we have to do is add the corresponding validation tag (Attributes) to each property of the model class and let the MVC3 framework do the validation
API development often encountered some validation of the request data, at this time if the use of annotations there are two benefits, one is the validation logic and business logic separation, code clear, and the second is the validation logic can be easily reused, just need to verify the place to add annotations.
Jav
It is common to verify the data to be written before it is written to the database, avoiding more serious security issues such as generic SQL injection attacks.
Mayfish can flexibly customize the validation rules for the data content that will be written, to reduce the hassle of manually verifying data for each field b
How does Excel set clear data validation? The validity of the data is set in the table, and we will not be able to fill in any other error. Modify the table to determine the validity of the data, it is necessary to clear the data validat
Use PHP's own filter function for data validationPHP filters contain two types ofValidation: used to verify that a validation entry is validsanitization: used to format the validated item, so it may modify the value of the validation entry, remove the illegal character, and so on.Input_filters_list ()Used to list all filters supported by the current system. Th
So easy~--whFirst, what is the data check?This is a good understanding, is used to verify that the customer input data is legitimate, such as customer login, user name can not be empty, or can not exceed the specified length and other requirements, this is called data validation.The data check is divided into the clien
The rules for executable validation areNotempty cannot be emptyNumber can only be an integerIsemail Mailbox address is correctWhether the Hasone is unique (duplicates, whether it already exists)Regex Custom Regular expression
The format of the validation isArray (validation method, field name for validation, prompt fo
Source of demand:In the daily work, business process is often a lot of continuous data flow, processing, presentation process, in this process, the inevitable is the work of data validation. Data validation work is a tedious repetition of labor, there is no technical content
transferred to the server after the client's verification. We first verify that the user name is not empty, how to do it?To get the idea right, we can do it in 3 steps:1. Declare a custom attribute.2. Add a custom attribute to the user class.3, through the characteristics of the data to achieve the verification.Declares a custom attribute.1 [AttributeUsage (attributetargets.property)]2 classRequiredattribute:attribute3 {4 /// 5
length of 5 -Maxlength3:Ten, toCheckchartype: [true,false,false,NULL] + }, - "X.sex":{//input box that needs to be validated name theRequiredtrue,//verification Condition: Required *Minlength2:5,//validation Condition: Minimum length of 5 $Maxlength2:TenPanax Notoginseng }, - }, the messages:{ + "X.name":{ ARequired:"cannot be empty", theMinLength:"the minimum value is 5" + }, -
This blog post mainly summarizes the validation of data in Springmvc. In practice, often use more is the front-end of the check, such as the page JS check, for high security requirements of the recommendations on the service side also to be verified. The service-side check can be in the control layer Conroller, can also be in the business layer Service,controller Verify the validity of the parameters of th
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.