WO2021249356A1 - Form data verification method, system, server, and user terminal - Google Patents

Form data verification method, system, server, and user terminal Download PDF

Info

Publication number
WO2021249356A1
WO2021249356A1 PCT/CN2021/098730 CN2021098730W WO2021249356A1 WO 2021249356 A1 WO2021249356 A1 WO 2021249356A1 CN 2021098730 W CN2021098730 W CN 2021098730W WO 2021249356 A1 WO2021249356 A1 WO 2021249356A1
Authority
WO
WIPO (PCT)
Prior art keywords
form data
data
verification
page
field
Prior art date
Application number
PCT/CN2021/098730
Other languages
French (fr)
Chinese (zh)
Inventor
荆伟
徐伟伟
李雄杰
Original Assignee
苏宁易购集团股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏宁易购集团股份有限公司 filed Critical 苏宁易购集团股份有限公司
Publication of WO2021249356A1 publication Critical patent/WO2021249356A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Definitions

  • This application relates to the technical field of software development, in particular to a form data verification method, system, server and user terminal.
  • the verification of the form data includes front-end JavaScript verification and back-end Java layer verification. After the form data is verified by the front desk, the back end will verify the form data again.
  • the disadvantage of the above-mentioned first method is that developers need to write the verification code of the foreground and the background separately, which is prone to inconsistency of the verification results of the front and the background, and the hard code is not reusable, and two verification codes are written.
  • the amount is large; the second method above also requires developers to separately write the verification code of the foreground and the background, so it is also prone to inconsistent verification results between the front and the back, although the verification rules of the field can be described by the developer through annotations.
  • the backend can only perform simple verification on form data, but cannot perform complex verification on form data, such as verification methods such as business data verification or logic verification .
  • the present invention provides a form data verification method, system, server and user terminal.
  • the embodiments of the present invention can reduce the amount of code that developers need to write, and allow developers to code a small amount of code to achieve verification.
  • the function of verifying form data, and the backend, that is, the server, can also verify the form data using complex verification methods, and there will be no inconsistencies in the verification results of the front and back ends.
  • the present invention provides a form data verification method according to the first aspect.
  • the method includes:
  • the form data verification file Send the form page and the form data verification file to the user terminal so that the user terminal displays the form page, and when it detects the form data submission instruction issued by the user through the form page, the form data verification file is used to verify the file Verify the form data associated with the form data submission instruction;
  • the form page includes at least one form field; determining the form data verification rule corresponding to the form page includes: parsing the form page through a custom template tag in the form page to obtain the form page Corresponding form data verification rules, the form data verification rules include verification rules corresponding to each form field in the form page.
  • the verification rule corresponding to each form field is pre-embedded in the page label attribute of each form field; the form page is parsed through the custom template label in the form page to obtain the form page
  • the corresponding form data verification rules include: parse the page label of each form field in the form page through the custom template label in the form page to obtain the page label corresponding to the page label attribute embedded in each form field in advance Validation rules in.
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the form data includes at least one form field data
  • the form field data is data entered by the user for the form field in the form page
  • the form data submission request associated with the form data includes: receiving a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and verifies the file through the form data All form field data in the form data is verified and sent after the form data passes the verification.
  • the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, extracts the verification rule corresponding to each form field data in the form data from the form data verification file, and uses the extracted to The verification rules corresponding to each form field data in the form field data are verified and sent after the form data passes the verification.
  • verifying the form data according to the form data verification rule includes: extracting the verification rule corresponding to each form field data in the form data from the form data verification rule; using the extracted form data The verification rule corresponding to the data of each form field verifies the data of each form field.
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • determining the form data verification rule corresponding to the form page it includes: storing the form data verification rule in a cache; obtaining the form data verification rule includes: obtaining the form data verification rule from the cache. Inspection rules.
  • generating the form data verification file according to the form data verification rule includes: generating the form data verification file according to the verification rule corresponding to each form field in the form page, and the form data verification file is JavaScript files.
  • the present invention provides another form data verification method according to the second aspect.
  • the method includes:
  • the form page is a page generated after the server receives the form acquisition request.
  • the form data verification file is a form data verification file that the server determines the form page corresponds to. Verification rules, and files generated according to the form data verification rules;
  • a form data submission request associated with the form data is sent to the server.
  • the form data submission request is used to instruct the server to obtain the form data verification rule, and the form data verification rule The form data is verified.
  • verifying the form data associated with the form data submission instruction through the form data verification file includes: obtaining the form data associated with the form data submission instruction, the form data including at least one form field data,
  • the form field data is the data entered by the user for the form fields in the form page; the form data verification file is used to verify all the form field data in the form data.
  • verifying all form field data in the form data through the form data verification file includes: extracting the verification rules corresponding to each form field data in the form data from the form data verification file ; Use the verification rules corresponding to the extracted form field data to verify each form field data.
  • the form page includes at least one form field
  • the form data verification rule includes each of the form pages obtained by the server by parsing the form page through a custom template tag in the form page. The verification rule corresponding to the form field.
  • the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server uses a custom template in the form page.
  • the label is obtained by parsing the page label of each form field in the form page.
  • the form data submission request is used to instruct the server to obtain the form data verification rule, extract the verification rule corresponding to each form field data in the form data from the form data verification rule, and use the extracted to The verification rules corresponding to the data of each form field in, verify the data of each form field;
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • the form data verification file is a JavaScript file.
  • the server includes:
  • the form page generation module is used to receive the form acquisition request from the user terminal, and generate the form page corresponding to the form acquisition request;
  • the verification file generation module is used to determine the form data verification rule corresponding to the form page, and generate the form data verification file according to the form data verification rule;
  • the sending module is used to send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when it detects the form data submission instruction issued by the user through the form page, through the The form data verification file verifies the form data associated with the form data submission instruction;
  • the verification module is used to receive the form data submission request associated with the form data sent by the user terminal after the form data passes the verification, obtain the form data verification rule, and perform the form data verification according to the form data verification rule check.
  • the present invention provides a user terminal according to a fourth aspect.
  • the user terminal includes:
  • the acquisition request sending module is used to send a form acquisition request to the server to obtain a form page and a form data verification file.
  • the form page is a page generated by the server after receiving the form acquisition request
  • the form data verification file is the server Determine the form data verification rule corresponding to the form page, and generate the file according to the form data verification rule;
  • Display module used to display the form page
  • the verification module is used to verify the form data associated with the form data submission instruction through the form data verification file when the form data submission instruction issued by the user through the form page is detected;
  • the submission request sending module is used to send the form data submission request associated with the form data to the server after the form data passes the verification, and the form data submission request is used to instruct the server to obtain the form data verification rule, and The form data is verified according to the form data verification rule.
  • the present invention provides a form data verification system according to a fifth aspect.
  • the system includes: a user terminal and a server; wherein,
  • the user terminal sends a form acquisition request to the server
  • the server receives the form acquisition request, generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, generates a form data verification file according to the form data verification rule, and generates a form data verification file according to the form data verification rule.
  • the form data verification file is sent to the user terminal;
  • the user terminal After the user terminal obtains the form page and the form data verification file, it displays the form page.
  • the form data verification file is used to associate the form data submission instruction
  • the form data is verified, and after the form data passes the verification, a form data submission request associated with the form data is sent to the server;
  • the server receives the form data submission request, obtains the form data verification rule, and verifies the form data associated with the form data submission request according to the form data verification rule.
  • the server after receiving the form acquisition request from the user terminal, the server generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, and verifies the form data according to the form data.
  • the rule generates a form data verification file, and sends the form page and the form data verification file to the user terminal, so that the user terminal displays the form page and detects the form data submission instruction issued by the user through the form page
  • the form data associated with the form data submission instruction is verified by the form data verification file
  • the server receives the form data submission request associated with the form data sent by the user terminal after the form data has passed the verification .
  • the server can use complex verification methods to verify the form data.
  • the form data verification file is generated according to the form data verification rules, the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
  • FIG. 1 is a schematic diagram of related equipment in a form data verification system in an embodiment
  • FIG. 2 is a schematic diagram of the interaction flow between the server and the user terminal in the form data verification system in an embodiment
  • FIG. 3 is a schematic flowchart of a method for verifying form data in an embodiment
  • FIG. 4 is a schematic flowchart of another method for verifying form data in an embodiment
  • Figure 5 is a structural block diagram of a server in an embodiment
  • Figure 6 is a structural block diagram of a user terminal in an embodiment
  • Fig. 7 is an internal structure diagram of a computer device in an embodiment.
  • An embodiment of the present invention provides a form data verification system.
  • the system includes a server 10 and a user terminal 20.
  • the server 10 may be an independent server or a cluster composed of multiple servers.
  • the terminal 20 may be a computing device such as a smart phone, a notebook computer, a tablet computer, or a smart wearable device.
  • a server program is installed on the server 10
  • a client program corresponding to the server program is installed on the user terminal 20.
  • the interaction process between the server 10 and the user terminal 20 is from step S10 to step S40.
  • Step S10 The user terminal sends a form acquisition request to the server.
  • the user terminal may receive an instruction from the user and send a form acquisition request to the server in response to the instruction.
  • a form acquisition request is a page acquisition request used to obtain a page (ie a web page) from the server, such as http (HyperText Transfer Protocol) request, https (Hyper Text Transfer Protocol over SecureSocket Layer, HyperText Transfer Protocol) request ,
  • http HyperText Transfer Protocol
  • https Hyper Text Transfer Protocol over SecureSocket Layer, HyperText Transfer Protocol
  • the page acquisition request that contains the form in the page to be acquired is described as a form acquisition request.
  • the form is used in the web page to receive user input.
  • Step S20 The server receives the form acquisition request, generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, and generates a form data verification file according to the form data verification rule, and the form The page and the form data verification file are sent to the user terminal.
  • the server parses the form acquisition request to generate the form page.
  • the server can generate the form page through freeMark (a template engine that can generate text output based on the template).
  • the form page is an HTML file. Since the generated page belongs to the form page, that is, the page that contains the form, the server will then determine the form data verification rule corresponding to the form page.
  • the form page will include at least one form field, such as ordinary text box, text block, radio button, check box, etc., different form fields correspond to different fields to obtain different field information, for example, user The name field corresponds to a form field, and the password field corresponds to another form field.
  • the server when the server determines the form data verification rule corresponding to the form page, it parses the form page through the custom template tag in the form page to obtain the form data verification rule corresponding to the form page , So that developers only need to write the code of the form form in the early stage of development, add verification rules to the attributes of each form field in the form form, and add the relevant solution identifier in the back-end receiving interface to realize the connection between the server and the user terminal.
  • the form data is verified without writing JavaScript verification code for verifying the form data and java verification code for verifying the form data.
  • the verification rule may be specific rule description information.
  • the verification rule can also be a rule identifier that has a mapping relationship with the rule description information.
  • the mapping relationship between the rule description information and the rule identifier can be configured in the configuration file, so that developers only need to add the corresponding rule identifier when adding the verification rule There is no need to write specific rule description information, thereby further reducing the amount of code written by developers.
  • the configuration content of the configuration file may be the content shown below.
  • the form data verification rule includes the verification rule corresponding to each form field in the form page.
  • the form data verification rule includes a verification rule rule_a for verifying the form field data corresponding to the form field A, and a verification rule rule_b for verifying the form field data corresponding to the form field B.
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the verification rules corresponding to the form fields may include at least one of regular verification rules, logical verification rules, and business data verification rules. The verification rules corresponding to different form fields may be the same or partially the same.
  • the code fragment corresponding to the form on the form page is as follows:
  • the form page includes two fields, namely the user name "username” and the password "password".
  • the developer embeds the verification rules corresponding to these two fields into the code through a custom template tag
  • the server can parse through the custom template tag to obtain the verification rule corresponding to the username "username” as rule1, and the verification rule corresponding to the password "password” as rule2.
  • the verification rule corresponding to each form field is pre-embedded in the page label attribute of each form field by the developer in the early stage of development, that is, the attribute of the page label corresponding to each form field.
  • page tags refer to dom tags or HTML tags.
  • the page tags corresponding to the form fields can include but are not limited to ⁇ input> and ⁇ select>.
  • the server parses the form page through the custom template tag in the form page, and obtains the step of the form data verification rule corresponding to the form page. Specifically, the server uses the custom template tag in the form page for the form The page label of each form field in the page is parsed to obtain the verification rule in the page label corresponding to the page label attribute of the page label embedded in each form field in advance.
  • the server After the server determines the form data verification rule, it generates a form data verification file according to the form data verification rule, where the verification rule included in the form data verification rule and the verification rule included in the form data verification file.
  • the verification rules used by the server and the user terminal to verify the form data can be unified, thereby avoiding the situation where the front-end and back-end verification results are different.
  • the server generates the form data verification file according to the form data verification rule. Specifically, the server generates the form data verification file according to the verification rule corresponding to each form field in the form page. Specifically, the form data verification file is a JavaScript file, which is embedded in the form page.
  • Step S30 After the user terminal obtains the form page and the form data verification file, the form page is displayed, and when the form data submission instruction issued by the user through the form page is detected, the form data verification file is used to submit the form data The form data associated with the instruction is verified, and after the form data passes the verification, a form data submission request associated with the form data is sent to the server.
  • the user terminal After the user terminal obtains the form page from the server, it will start to load the HTML code in the form page, and then display the form page to the user.
  • the user can enter the form field data in the form field on the form page, for example, enter the user name information in the text box (form field) of the user name field.
  • the form data includes at least one form field data, and the form field data is data input by the user for the form field in the form page, that is, the data input by the user on the form field.
  • the form field data included in the form data may be the form field data corresponding to all the form fields on the form page, or the form corresponding to some form fields on the form page Field data.
  • the step of verifying the form data associated with the form data submission instruction by the user terminal through the form data verification file includes: obtaining the form data associated with the form data submission instruction by the user terminal; and verifying the form through the form data verification file All form field data in the data is verified.
  • the user terminal when the user terminal verifies all form field data in the form data through the form data verification file, it specifically extracts the verification rules corresponding to each form field data in the form data from the form data verification file , And then verify the data of each form field using the verification rules corresponding to the extracted data of each form field.
  • Step S40 The server receives the form data submission request, obtains the form data verification rule, and verifies the form data associated with the form data submission request according to the form data verification rule.
  • the server when the user terminal verifies the form data, and after the verification is passed, the form data is submitted to the server, and the server will verify the form data again after receiving the form data.
  • the server obtains the form data verification rule corresponding to the form data, and then verifies the form data according to the form data verification rule.
  • the server extracts the verification rule corresponding to each form field data in the form data from the form data verification rule, and then uses the verification rule corresponding to each extracted form field data to verify each form field data .
  • the server may store the form data verification rule in the cache.
  • the server when the server needs to obtain the form data verification rule after receiving the form data submission request, it can obtain the form data verification rule from the cache.
  • an embodiment of the present invention provides a form data verification method.
  • the following is an example of applying the method to the server in the above form data verification system. As shown in Figure 3, the method includes the following steps:
  • Step S110 Receive a form acquisition request from the user terminal, and generate a form page corresponding to the form acquisition request.
  • Step S120 Determine the form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule.
  • Step S130 Send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when detecting the form data submission instruction issued by the user through the form page, pass the form data
  • the verification file verifies the form data associated with the form data submission instruction.
  • Step S140 Receive the form data submission request associated with the form data sent by the user terminal after the form data passes the verification, obtain the form data verification rule, and verify the form data according to the form data verification rule.
  • This embodiment can reduce the amount of code that developers need to write when realizing the function of verifying form data, and enable the backend, that is, the server, to verify the form data using a complex verification method.
  • the backend that is, the server
  • the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
  • the form page includes at least one form field; determining the form data verification rule corresponding to the form page includes: parsing the form page through a custom template tag in the form page to obtain the form page Corresponding form data verification rules, the form data verification rules include verification rules corresponding to each form field in the form page.
  • the verification rule corresponding to each form field is embedded in the page label attribute of each form field in advance.
  • the form page is parsed through the custom template tag in the form page to obtain the form data verification rules corresponding to the form page, including: through the custom template tag in the form page, each form field in the form page Parse the page tags of each form field to obtain the verification rules in the page tag corresponding to the page tag attributes pre-embedded in each form field.
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the form data includes at least one form field data
  • the form field data is data input by the user for the form field in the form page
  • the form data submission request associated with the form data includes: receiving a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and verifies the file through the form data All form field data in the form data is verified and sent after the form data passes the verification.
  • the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, extracts the verification rule corresponding to each form field data in the form data from the form data verification file, and uses the extracted to The verification rules corresponding to each form field data in the form field data are verified and sent after the form data passes the verification;
  • verifying the form data according to the form data verification rule includes: extracting the verification rule corresponding to each form field data in the form data from the form data verification rule; using the extracted form data The verification rule corresponding to the data of each form field verifies the data of each form field.
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • determining the form data verification rule corresponding to the form page it includes: storing the form data verification rule in a cache; obtaining the form data verification rule includes: obtaining the form data verification rule from the cache. Inspection rules.
  • generating the form data verification file according to the form data verification rule includes: generating the form data verification file according to the verification rule corresponding to each form field in the form page, and the form data verification file is JavaScript files.
  • This embodiment is provided based on the same inventive concept as the first embodiment. Therefore, for the specific definition of the form data verification method provided in this embodiment, please refer to the definition of the interaction process between the server and the user terminal in the first embodiment. This will not be repeated here.
  • An embodiment of the present invention provides a method for verifying form data, and the method is applied to a user terminal in the foregoing form data verification system as an example for description. As shown in Figure 4, the method includes the following steps:
  • Step S210 Send a form acquisition request to the server to obtain a form page and a form data verification file.
  • the form page is a page generated after the server receives the form acquisition request.
  • the form data verification file is determined by the server to correspond to the form page Form data verification rules, and files generated according to the form data verification rules.
  • Step S220 Display the form page.
  • Step S230 When the form data submission instruction issued by the user through the form page is detected, the form data associated with the form data submission instruction is verified through the form data verification file.
  • Step S240 After the form data has passed the verification, a form data submission request associated with the form data is sent to the server, and the form data submission request is used to instruct the server to obtain the form data verification rule and verify according to the form data The rule checks the form data.
  • This embodiment can reduce the amount of code that developers need to write when realizing the function of verifying form data, and enable the backend, that is, the server, to verify the form data using a complex verification method.
  • the backend that is, the server
  • the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
  • verifying the form data associated with the form data submission instruction through the form data verification file includes:
  • Acquiring form data associated with the form data submission instruction including at least one form field data, and the form field data is data input by the user for the form field in the form page;
  • verifying all form field data in the form data through the form data verification file includes:
  • the form page includes at least one form field
  • the form data verification rule includes each of the form pages obtained by the server by parsing the form page through a custom template tag in the form page. The verification rule corresponding to the form field.
  • the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server uses a custom template in the form page.
  • the label is obtained by parsing the page label of each form field in the form page.
  • the form data submission request is used to instruct the server to obtain the form data verification rule, extract the verification rule corresponding to each form field data in the form data from the form data verification rule, and use the extracted to The verification rules corresponding to the data of each form field in, verify the data of each form field;
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • the form data verification file is a JavaScript file.
  • This embodiment is provided based on the same inventive concept as the first embodiment. Therefore, for the specific definition of the form data verification method provided in this embodiment, please refer to the definition of the interaction process between the server and the user terminal in the first embodiment. This will not be repeated here.
  • the server includes the following modules: a form page generation module 110, which is used to receive a form acquisition request from a user terminal, Generate a form page corresponding to the form acquisition request; a verification file generating module 120, configured to determine a form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule; and
  • the module 130 is configured to send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when it is detected that the user issued the form page through the form page
  • the verification module 140 is configured to receive the user terminal after the form data has passed verification
  • the sent form data submission request associated with the form data obtains the form data verification rule, and verifies the form data according to the form data verification rule.
  • the form page includes at least one form field
  • the verification file generation module includes: a parsing sub-module for parsing the form page through a custom template tag in the form page to obtain the form data verification rule corresponding to the form page, the form data
  • the verification rule includes a verification rule corresponding to each form field in the form page.
  • the verification rule corresponding to each form field is embedded in the page label attribute of each form field in advance;
  • the parsing sub-module is also used to parse the page label of each form field in the form page through the custom template label in the form page to obtain the corresponding page label embedded in each form field in advance Validation rules in page label properties.
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the form data includes at least one form field data, and the form field data is data input by a user for a form field in the form page;
  • the verification module includes: a submission request receiving sub-module, configured to receive a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction through
  • the form data verification file verifies all form field data in the form data and is sent after the form data passes the verification.
  • the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and extracts data corresponding to each form field in the form data from the form data verification file
  • the verification rule is used to verify the respective form field data using the verification rule corresponding to each extracted form field data and is sent after the form data passes the verification.
  • the verification module includes: a rule extraction sub-module, which is used to extract a verification rule corresponding to each form field data in the form data from the form data verification rule; the verification sub-module uses To verify the data of each form field using a verification rule corresponding to the extracted data of each form field;
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • the server further includes a storage module; the storage module is configured to store the form data verification rule in a cache after the form data verification rule corresponding to the form page is determined.
  • the verification module when used to obtain the form data verification rule, it is specifically used to obtain the form data verification rule from the cache.
  • the verification file generation module is further configured to generate a form data verification file according to a verification rule corresponding to each form field in the form page, and the form data verification file is a JavaScript file.
  • each module in the above-mentioned server can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • an embodiment of the present invention provides a user terminal.
  • the user terminal includes the following modules: an acquisition request sending module 210, which is used to send a form acquisition request to a server To obtain a form page and a form data verification file, the form page is a page generated after the server receives the form acquisition request, and the form data verification file is a form that the server determines that the form page corresponds to Data verification rules, and files generated according to the form data verification rules; display module 220, used to display the form page; verification module 230, used to detect the form issued by the user through the form page When submitting a data instruction, verify the form data associated with the form data submission instruction through the form data verification file; the submission request sending module 240 is configured to send the form data to the server after the form data has passed the verification. Send a form data submission request associated with the form data, where the form data submission request is used to instruct the server to obtain the form data verification rule, and to verify the form data according to the form data verification
  • the verification module includes: a form data acquisition sub-module for acquiring form data associated with the form data submission instruction, the form data includes at least one form field data, and the form field data is a user For the data entered in the form fields in the form page; a verification sub-module for verifying all form field data in the form data through the form data verification file;
  • the verification sub-module includes: a rule extraction unit for extracting a verification rule corresponding to each form field data in the form data from the form data verification file; a verification unit for The verification rules corresponding to the extracted form field data are used to verify the respective form field data.
  • the form page includes at least one form field
  • the form data verification rule includes the information obtained by the server from parsing the form page through a custom template tag in the form page. The verification rule corresponding to each of the form fields in the form page.
  • the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server passes through the form page
  • the custom template tag is obtained by parsing the page tag of each form field in the form page.
  • the form data submission request is used to instruct the server to obtain the form data verification rule, and extract the verification corresponding to each form field data in the form data from the form data verification rule Rule, using the extracted verification rules corresponding to the extracted form field data to verify the respective form field data.
  • the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  • the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
  • the form data verification file is a JavaScript file.
  • Each module in the above-mentioned user terminal may be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • An embodiment of the present invention provides a computer device, and its internal structure diagram may be as shown in FIG. 7.
  • the computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store data such as form data verification rules.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the processor implements the steps of the form data verification method described in Embodiment 2 or Embodiment 3 when the processor executes the computer program.
  • FIG. 7 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • the specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
  • An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored.

Abstract

A form data verification method, a server, a user terminal, and a system. The method comprises: after receiving a form acquisition request of a user terminal, a server generates a form page corresponding to the request, determines a form data verification rule corresponding to the form page, generates a form data verification file on the basis of the verification rule, and sends the form page and the verification file to the user terminal; the user terminal displays the form page and, when detecting a form data submission command issued by the user by means of the form page, verifies the form data associated with the submission command by means of the verification file; and, after receiving a form data submission request sent by the user terminal and associated with the verified form data, the server acquires the verification rule and verifies the form data on the basis of the verification rule, thereby reducing the amount of code that a developer needs to write to implement a form data verification function.

Description

表单数据校验方法、系统、服务器和用户终端Form data verification method, system, server and user terminal 技术领域Technical field
本申请涉及软件开发技术领域,特别是涉及一种表单数据校验方法、系统、服务器和用户终端。This application relates to the technical field of software development, in particular to a form data verification method, system, server and user terminal.
背景技术Background technique
在提交表单数据的场景中,通常需要对提交的表单数据进行验证,而对表单数据进行验证包括前台JavaScript验证和后台Java层验证,即在提交表单数据时,前台对表单数据进行一次验证,当表单数据通过前台验证后,后台再对该表单数据进行一次验证。In the scenario of submitting form data, it is usually necessary to verify the submitted form data, and the verification of the form data includes front-end JavaScript verification and back-end Java layer verification. After the form data is verified by the front desk, the back end will verify the form data again.
在目前的Java Web软件开发过程中,为了实现对表单数据进行验证的功能,一种方式是由开发人员编写form表单,编写用于对表单数据进行校验的JavaScript校验代码,以及用于接收来自前台的表单数据并对表单数据进行校验的java校验代码;另一种方式是由开发人员编写form表单,使用JavaScript框架进行简单的数据校验,以及在后台bean文件增加注解,通过注解描述表单字段的校验规则。In the current Java Web software development process, in order to achieve the function of verifying form data, one way is for developers to write form forms, write JavaScript verification codes for verifying form data, and receive The java verification code for the form data from the front desk to verify the form data; another way is to write the form form by the developer, use the JavaScript framework to perform simple data verification, and add annotations to the back-end bean file through annotations Describe the validation rules for form fields.
技术问题technical problem
上述第一种方式的不足是开发人员需要分开编写前台和后台的校验代码,这样容易出现前后台校验结果不一致的问题,并且硬代码编写没有复用性,两份校验代码的编写工作量较大;上述第二种方式同样需要开发人员分开编写前台和后台的校验代码,因而也容易出现前后台校验结果不一致的问题,虽然通过开发人员可以注解来描述字段的校验规则进而减少需要编写的代码量,然而使用这种方式开发时,后台只能对表单数据进行简单校验,而无法对表单数据进行复杂的校验,比如业务数据校验或逻辑校验等校验方式。The disadvantage of the above-mentioned first method is that developers need to write the verification code of the foreground and the background separately, which is prone to inconsistency of the verification results of the front and the background, and the hard code is not reusable, and two verification codes are written. The amount is large; the second method above also requires developers to separately write the verification code of the foreground and the background, so it is also prone to inconsistent verification results between the front and the back, although the verification rules of the field can be described by the developer through annotations. Reduce the amount of code that needs to be written. However, when developing in this way, the backend can only perform simple verification on form data, but cannot perform complex verification on form data, such as verification methods such as business data verification or logic verification .
技术解决方案Technical solutions
本发明针对现有技术的缺点,提供了一种表单数据校验方法、系统、服务器和用户终端,本发明实施例能够减少开发人员需要编写的代码量,让开发人员编码少量代码即可实现对表单数据进行验证的功能,而后台即服务器也能够使用复杂的校验方式对表单数据进行校验,并且不会出现前后台校验结果不一致的情况。In view of the shortcomings of the prior art, the present invention provides a form data verification method, system, server and user terminal. The embodiments of the present invention can reduce the amount of code that developers need to write, and allow developers to code a small amount of code to achieve verification. The function of verifying form data, and the backend, that is, the server, can also verify the form data using complex verification methods, and there will be no inconsistencies in the verification results of the front and back ends.
本发明根据第一方面提供了一种表单数据校验方法,在一个实施例中,该方法包括:The present invention provides a form data verification method according to the first aspect. In an embodiment, the method includes:
接收用户终端的表单获取请求,生成与该表单获取请求对应的表单页面;Receive a form acquisition request from the user terminal, and generate a form page corresponding to the form acquisition request;
确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件;Determine the form data verification rule corresponding to the form page, and generate the form data verification file according to the form data verification rule;
将该表单页面和该表单数据校验文件发送给用户终端,以使用户终端展示该表单页面,并在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验;Send the form page and the form data verification file to the user terminal so that the user terminal displays the form page, and when it detects the form data submission instruction issued by the user through the form page, the form data verification file is used to verify the file Verify the form data associated with the form data submission instruction;
接收用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求,获取该表单数据校验规则,根据该表单数据校验规则对该表单数据进行校验。Receive the form data submission request associated with the form data sent by the user terminal after the form data has passed the verification, obtain the form data verification rule, and verify the form data according to the form data verification rule.
在一个实施例中,该表单页面包括至少一个表单字段;确定该表单页面对应的表单数据校验规则,包括:通过该表单页面中的自定义模板标签对该表单页面进行解析,得到该表单页面对应的表单数据校验规则,该表单数据校验规则包括该表单页面中每个表单字段对应的校验规则。In one embodiment, the form page includes at least one form field; determining the form data verification rule corresponding to the form page includes: parsing the form page through a custom template tag in the form page to obtain the form page Corresponding form data verification rules, the form data verification rules include verification rules corresponding to each form field in the form page.
在一个实施例中,每个表单字段对应的校验规则预先嵌于该每个表单字段的页面标签属性中;通过该表单页面中的自定义模板标签对该表单页面进行解析,得到该表单页面对应的表单数据校验规则,包括:通过该表单页面中的自定义模板标签对该表单页面中每个表单字段的页面标签进行解析,得到预先嵌于每个表单字段的页面标签对应页面标签属性中的校验规则。In one embodiment, the verification rule corresponding to each form field is pre-embedded in the page label attribute of each form field; the form page is parsed through the custom template label in the form page to obtain the form page The corresponding form data verification rules include: parse the page label of each form field in the form page through the custom template label in the form page to obtain the page label corresponding to the page label attribute embedded in each form field in advance Validation rules in.
在一个实施例中,表单字段对应的校验规则用于校验该表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施例中,该表单数据包括至少一个表单字段数据,该表单字段数据是用户针对该表单页面中的表单字段输入的数据;该接收该用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求,包括:接收该用户终端发送的表单数据提交请求,该表单数据提交请求是该用户终端获取该表单数据提交指令关联的表单数据,通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验并在该表单数据通过校验后发送的。In one embodiment, the form data includes at least one form field data, the form field data is data entered by the user for the form field in the form page; the receiving and sending of the user terminal after the form data passes the verification The form data submission request associated with the form data includes: receiving a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and verifies the file through the form data All form field data in the form data is verified and sent after the form data passes the verification.
在一个实施例中,表单数据提交请求是用户终端获取该表单数据提交指令关联的表单数据,从该表单数据校验文件中提取该表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验并在该表单数据通过校验后发送的。In one embodiment, the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, extracts the verification rule corresponding to each form field data in the form data from the form data verification file, and uses the extracted to The verification rules corresponding to each form field data in the form field data are verified and sent after the form data passes the verification.
在一个实施例中,根据该表单数据校验规则对该表单数据进行校验,包括:从该表单数据校验规则中提取该表单数据中各个表单字段数据对应的校验规则;使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。In one embodiment, verifying the form data according to the form data verification rule includes: extracting the verification rule corresponding to each form field data in the form data from the form data verification rule; using the extracted form data The verification rule corresponding to the data of each form field verifies the data of each form field.
在一个实施例中,表单数据校验规则包括的校验规则与表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施例中,确定该表单页面对应的表单数据校验规则之后,包括:将该表单数据校验规则存入缓存;获取该表单数据校验规则,包括:从缓存中获取该表单数据校验规则。In one embodiment, after determining the form data verification rule corresponding to the form page, it includes: storing the form data verification rule in a cache; obtaining the form data verification rule includes: obtaining the form data verification rule from the cache. Inspection rules.
在一个实施例中,根据该表单数据校验规则生成表单数据校验文件,包括:根据该表单页面中每个表单字段对应的校验规则生成表单数据校验文件,该表单数据校验文件是JavaScript文件。In one embodiment, generating the form data verification file according to the form data verification rule includes: generating the form data verification file according to the verification rule corresponding to each form field in the form page, and the form data verification file is JavaScript files.
本发明根据第二方面提供了另一种表单数据校验方法,在一个实施例中,该方法包括:The present invention provides another form data verification method according to the second aspect. In one embodiment, the method includes:
向服务器发送表单获取请求以获得表单页面和表单数据校验文件,该表单页面是服务器接收到该表单获取请求后生成的页面,该表单数据校验文件是服务器确定该表单页面对应的表单数据校验规则,并根据该表单数据校验规则生成的文件;Send a form acquisition request to the server to obtain a form page and a form data verification file. The form page is a page generated after the server receives the form acquisition request. The form data verification file is a form data verification file that the server determines the form page corresponds to. Verification rules, and files generated according to the form data verification rules;
展示该表单页面;Display the form page;
在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验;When detecting the form data submission instruction issued by the user through the form page, verify the form data associated with the form data submission instruction through the form data verification file;
在该表单数据通过校验后,向服务器发送与该表单数据关联的表单数据提交请求,该表单数据提交请求用于指示服务器获取该表单数据校验规则,并根据该表单数据校验规则对该表单数据进行校验。After the form data has passed the verification, a form data submission request associated with the form data is sent to the server. The form data submission request is used to instruct the server to obtain the form data verification rule, and the form data verification rule The form data is verified.
在一个实施例中,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验,包括:获取该表单数据提交指令关联的表单数据,该表单数据包括至少一个表单字段数据,该表单字段数据是用户针对该表单页面中的表单字段输入的数据;通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验。In one embodiment, verifying the form data associated with the form data submission instruction through the form data verification file includes: obtaining the form data associated with the form data submission instruction, the form data including at least one form field data, The form field data is the data entered by the user for the form fields in the form page; the form data verification file is used to verify all the form field data in the form data.
在一个实施例中,通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验,包括:从该表单数据校验文件中提取该表单数据中各个表单字段数据对应的校验规则;使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。In one embodiment, verifying all form field data in the form data through the form data verification file includes: extracting the verification rules corresponding to each form field data in the form data from the form data verification file ; Use the verification rules corresponding to the extracted form field data to verify each form field data.
在一个实施例中,该表单页面包括至少一个表单字段,该表单数据校验规则包括该服务器通过该表单页面中的自定义模板标签对该表单页面进行解析而获得的该表单页面中每个该表单字段对应的校验规则。In one embodiment, the form page includes at least one form field, and the form data verification rule includes each of the form pages obtained by the server by parsing the form page through a custom template tag in the form page. The verification rule corresponding to the form field.
在一个实施例中,该表单数据校验规则包括的每个表单字段对应的校验规则预先嵌于该每个表单字段的页面标签属性中,是该服务端通过该表单页面中的自定义模板标签对该表单页面中每个表单字段的页面标签进行解析而得到的。In one embodiment, the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server uses a custom template in the form page. The label is obtained by parsing the page label of each form field in the form page.
在一个实施例中,该表单数据提交请求用于指示该服务器获取该表单数据校验规则,从该表单数据校验规则中提取该表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验;In one embodiment, the form data submission request is used to instruct the server to obtain the form data verification rule, extract the verification rule corresponding to each form field data in the form data from the form data verification rule, and use the extracted to The verification rules corresponding to the data of each form field in, verify the data of each form field;
在一个实施例中,该表单字段对应的校验规则用于校验该表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施例中,该表单数据校验规则包括的校验规则与该表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施例中,该表单数据校验文件是JavaScript文件。In one embodiment, the form data verification file is a JavaScript file.
本发明根据第三方面提供了一种服务器,在一个实施例中,该服务器包括:The present invention provides a server according to the third aspect. In one embodiment, the server includes:
表单页面生成模块,用于接收用户终端的表单获取请求,生成与该表单获取请求对应的表单页面;The form page generation module is used to receive the form acquisition request from the user terminal, and generate the form page corresponding to the form acquisition request;
校验文件生成模块,用于确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件;The verification file generation module is used to determine the form data verification rule corresponding to the form page, and generate the form data verification file according to the form data verification rule;
发送模块,用于将该表单页面和该表单数据校验文件发送给用户终端,以使用户终端展示该表单页面,并在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验;The sending module is used to send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when it detects the form data submission instruction issued by the user through the form page, through the The form data verification file verifies the form data associated with the form data submission instruction;
校验模块,用于接收用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求,获取该表单数据校验规则,根据该表单数据校验规则对该表单数据进行校验。The verification module is used to receive the form data submission request associated with the form data sent by the user terminal after the form data passes the verification, obtain the form data verification rule, and perform the form data verification according to the form data verification rule check.
本发明根据第四方面提供了一种用户终端,在一个实施例中,该用户终端包括:The present invention provides a user terminal according to a fourth aspect. In an embodiment, the user terminal includes:
获取请求发送模块,用于向服务器发送表单获取请求以获得表单页面和表单数据校验文件,该表单页面是该服务器接收到该表单获取请求后生成的页面,该表单数据校验文件是该服务器确定该表单页面对应的表单数据校验规则,并根据该表单数据校验规则生成的文件;The acquisition request sending module is used to send a form acquisition request to the server to obtain a form page and a form data verification file. The form page is a page generated by the server after receiving the form acquisition request, and the form data verification file is the server Determine the form data verification rule corresponding to the form page, and generate the file according to the form data verification rule;
展示模块,用于展示该表单页面;Display module, used to display the form page;
校验模块,用于在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验;The verification module is used to verify the form data associated with the form data submission instruction through the form data verification file when the form data submission instruction issued by the user through the form page is detected;
提交请求发送模块,用于在该表单数据通过校验后,向该服务器发送与该表单数据关联的表单数据提交请求,该表单数据提交请求用于指示该服务器获取该表单数据校验规则,并根据该表单数据校验规则对该表单数据进行校验。The submission request sending module is used to send the form data submission request associated with the form data to the server after the form data passes the verification, and the form data submission request is used to instruct the server to obtain the form data verification rule, and The form data is verified according to the form data verification rule.
本发明根据第五方面提供了一种表单数据校验系统,在一个实施例中,该系统包括:用户终端和服务器;其中,The present invention provides a form data verification system according to a fifth aspect. In one embodiment, the system includes: a user terminal and a server; wherein,
用户终端向服务器发送表单获取请求;The user terminal sends a form acquisition request to the server;
服务器接收该表单获取请求,生成与该表单获取请求对应的表单页面,确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件,将该表单页面和该表单数据校验文件发送给用户终端;The server receives the form acquisition request, generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, generates a form data verification file according to the form data verification rule, and generates a form data verification file according to the form data verification rule. The form data verification file is sent to the user terminal;
用户终端获得表单页面和表单数据校验文件后,展示该表单页面,在检测到用户通过该表单页面下发的表单数据提交指令时,使用该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验,在该表单数据通过校验后,向服务器发送与该表单数据关联的表单数据提交请求;After the user terminal obtains the form page and the form data verification file, it displays the form page. When detecting the form data submission instruction issued by the user through the form page, the form data verification file is used to associate the form data submission instruction The form data is verified, and after the form data passes the verification, a form data submission request associated with the form data is sent to the server;
服务器接收该表单数据提交请求,获取该表单数据校验规则,根据该表单数据校验规则对该表单数据提交请求关联的该表单数据进行校验。The server receives the form data submission request, obtains the form data verification rule, and verifies the form data associated with the form data submission request according to the form data verification rule.
有益效果Beneficial effect
在本发明的上述实施例中,服务器在接收到用户终端的表单获取请求后,生成与该表单获取请求对应的表单页面,确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件,并将该表单页面和该表单数据校验文件发送给用户终端,以使该用户终端展示该表单页面并在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验;服务器在接收到用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求后,获取该表单数据校验规则并根据该表单数据校验规则对该表单数据进行校验,从而能够减少开发人员在实现对表单数据进行验证的功能时所需要编写的代码量,并且能让后台即服务器能够使用复杂的校验方式对表单数据进行校验。此外,由于表单数据校验文件是根据表单数据校验规则生成的,所以前后台对表单数据进行校验所采用的校验规则是一致的,因而不会出现前后台校验结果不一致的情况。In the above-mentioned embodiment of the present invention, after receiving the form acquisition request from the user terminal, the server generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, and verifies the form data according to the form data. The rule generates a form data verification file, and sends the form page and the form data verification file to the user terminal, so that the user terminal displays the form page and detects the form data submission instruction issued by the user through the form page When the form data is verified, the form data associated with the form data submission instruction is verified by the form data verification file; after the server receives the form data submission request associated with the form data sent by the user terminal after the form data has passed the verification , To obtain the form data verification rule and verify the form data according to the form data verification rule, thereby reducing the amount of code that developers need to write when implementing the function of verifying form data, and allowing the background That is, the server can use complex verification methods to verify the form data. In addition, since the form data verification file is generated according to the form data verification rules, the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
附图说明Description of the drawings
图1为一个实施例中一种表单数据校验系统中相关设备的示意图;FIG. 1 is a schematic diagram of related equipment in a form data verification system in an embodiment;
图2为一个实施例中表单数据校验系统中的服务器与用户终端的交互流程示意图;FIG. 2 is a schematic diagram of the interaction flow between the server and the user terminal in the form data verification system in an embodiment;
图3为一个实施例中一种表单数据校验方法的流程示意图;FIG. 3 is a schematic flowchart of a method for verifying form data in an embodiment;
图4为一实施例中另一种表单数据校验方法的流程示意图;4 is a schematic flowchart of another method for verifying form data in an embodiment;
图5为一个实施例中一种服务器的结构框图;Figure 5 is a structural block diagram of a server in an embodiment;
图6为一个实施例中一种用户终端的结构框图;Figure 6 is a structural block diagram of a user terminal in an embodiment;
图7为一个实施例中计算机设备的内部结构图。Fig. 7 is an internal structure diagram of a computer device in an embodiment.
本发明的实施方式Embodiments of the present invention
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not used to limit the present application.
实施例一Example one
本发明一个实施例提供了一种表单数据校验系统,如图1所示,该系统包括服务器10和用户终端20,其中,服务器10可以是独立服务器或多个服务器组成的集群来实现,用户终端20可以是智能手机、笔记本电脑、平板电脑、智能穿戴设备等计算设备。进一步地,服务器10上安装有服务端程序,用户终端20上安装有与服务端程序对应的客户端程序。An embodiment of the present invention provides a form data verification system. As shown in FIG. 1, the system includes a server 10 and a user terminal 20. The server 10 may be an independent server or a cluster composed of multiple servers. The terminal 20 may be a computing device such as a smart phone, a notebook computer, a tablet computer, or a smart wearable device. Further, a server program is installed on the server 10, and a client program corresponding to the server program is installed on the user terminal 20.
如图2所示,服务器10和用户终端20之间的交互过程步骤S10-步骤S40。As shown in FIG. 2, the interaction process between the server 10 and the user terminal 20 is from step S10 to step S40.
步骤S10:用户终端向服务器发送表单获取请求。Step S10: The user terminal sends a form acquisition request to the server.
在本实施例中,用户终端可以接收用户的指令并响应于该指令向服务器发送表单获取请求。表单获取请求是用于向服务器获取页面(即网页)的页面获取请求,如http(HyperText Transfer Protocol,超文本传输协议)请求、https(Hyper Text Transfer Protocol over SecureSocket Layer,超文本传输安全协议)请求,为了方便描述,将要获取的页面中包含有表单的页面获取请求描述为表单获取请求。其中,表单在网页中用于接收用户的输入。In this embodiment, the user terminal may receive an instruction from the user and send a form acquisition request to the server in response to the instruction. A form acquisition request is a page acquisition request used to obtain a page (ie a web page) from the server, such as http (HyperText Transfer Protocol) request, https (Hyper Text Transfer Protocol over SecureSocket Layer, HyperText Transfer Protocol) request , For the convenience of description, the page acquisition request that contains the form in the page to be acquired is described as a form acquisition request. Among them, the form is used in the web page to receive user input.
步骤S20:服务器接收该表单获取请求,生成与该表单获取请求对应的表单页面,确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件,将该表单页面和该表单数据校验文件发送给用户终端。Step S20: The server receives the form acquisition request, generates a form page corresponding to the form acquisition request, determines the form data verification rule corresponding to the form page, and generates a form data verification file according to the form data verification rule, and the form The page and the form data verification file are sent to the user terminal.
在本实施例中,服务器接收到表单获取请求后,会对表单获取请求进行解析进而生成表单页面,具体地,服务器可以通过freeMark(一个模板引擎,能基于模板生成文本输出)来生成表单页面,其中,表单页面是一个HTML文件。由于生成的页面属于表单页面即包含表单的页面,因而服务器会再确定该表单页面对应的表单数据校验规则。其中,表单页面中会包括至少一个表单字段,比如,普通文本框,文本块,单选框,复选框等等,不同的表单字段对应不同的字段,以获取不同的字段信息,比如,用户名这个字段会对应一个表单字段,密码这个字段会对应的另一个表单字段。In this embodiment, after the server receives the form acquisition request, it parses the form acquisition request to generate the form page. Specifically, the server can generate the form page through freeMark (a template engine that can generate text output based on the template). Among them, the form page is an HTML file. Since the generated page belongs to the form page, that is, the page that contains the form, the server will then determine the form data verification rule corresponding to the form page. Among them, the form page will include at least one form field, such as ordinary text box, text block, radio button, check box, etc., different form fields correspond to different fields to obtain different field information, for example, user The name field corresponds to a form field, and the password field corresponds to another form field.
在一个实施方式中,服务器在确定该表单页面对应的表单数据校验规则时,通过该表单页面中的自定义模板标签对该表单页面进行解析,从而得到该表单页面对应的表单数据校验规则,从而开发人员在前期开发时,只需要编写form表单的代码,在form表单中各表单字段的属性中添加校验规则,并在后台接收接口添加相关注解标识即可实现在服务器和用户终端对表单数据进行校验,而无需编写用于对表单数据进行校验的JavaScript校验代码,以及用于对表单数据进行校验的java校验代码。进一步地,校验规则可以是具体的规则描述信息。校验规则也可以是与规则描述信息具有映射关系的规则标识,规则描述信息与规则标识的映射关系可以配置在配置文件中,这样开发人员在添加校验规则时,只需要添加相应的规则标识而不需要编写具体的规则描述信息,从而进一步减少开发人员的代码编写量。In one embodiment, when the server determines the form data verification rule corresponding to the form page, it parses the form page through the custom template tag in the form page to obtain the form data verification rule corresponding to the form page , So that developers only need to write the code of the form form in the early stage of development, add verification rules to the attributes of each form field in the form form, and add the relevant solution identifier in the back-end receiving interface to realize the connection between the server and the user terminal. The form data is verified without writing JavaScript verification code for verifying the form data and java verification code for verifying the form data. Further, the verification rule may be specific rule description information. The verification rule can also be a rule identifier that has a mapping relationship with the rule description information. The mapping relationship between the rule description information and the rule identifier can be configured in the configuration file, so that developers only need to add the corresponding rule identifier when adding the verification rule There is no need to write specific rule description information, thereby further reducing the amount of code written by developers.
示例性地,配置文件的配置内容可以为以下所示内容。Exemplarily, the configuration content of the configuration file may be the content shown below.
Figure 891944dest_path_image002
Figure 891944dest_path_image002
具体地,表单数据校验规则包括表单页面中每个表单字段对应的校验规则,比如,表单页面中有两个表单字段,用于获取用户名的表单字段A和用于获取密码的表单字段B,则表单数据校验规则包括用于校验表单字段A对应的表单字段数据的校验规则rule_a,以及用于校验表单字段B对应的表单字段数据的校验规则rule_b。其中,表单字段对应的校验规则用于校验该表单字段对应的表单字段数据。进一步地,表单字段对应的校验规则可以包括正则校验规则、逻辑校验规则和业务数据校验规则中的至少一项,不同表单字段对应的校验规则可以相同或部分相同。Specifically, the form data verification rule includes the verification rule corresponding to each form field in the form page. For example, there are two form fields in the form page, form field A for obtaining the user name and form field for obtaining the password. B, the form data verification rule includes a verification rule rule_a for verifying the form field data corresponding to the form field A, and a verification rule rule_b for verifying the form field data corresponding to the form field B. Wherein, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field. Further, the verification rules corresponding to the form fields may include at least one of regular verification rules, logical verification rules, and business data verification rules. The verification rules corresponding to different form fields may be the same or partially the same.
示例性地,在一个用户登录场景中,表单页面中的表单对应的代码片段如下:Exemplarily, in a user login scenario, the code fragment corresponding to the form on the form page is as follows:
Figure dest_path_image004a
Figure dest_path_image004a
在上述代码片段中,表单页面中包括两个字段,即用户名"username"和密码"password",开发人员在前期开发时,将这两个字段对应的校验规则通过自定义模板标签嵌入代码片段中,这样服务器可以通过自定义模板标签解析得到用户名"username"对应的校验规则为rule1,密码"password"对应的校验规则为rule2。In the above code snippet, the form page includes two fields, namely the user name "username" and the password "password". During the early development, the developer embeds the verification rules corresponding to these two fields into the code through a custom template tag In the snippet, the server can parse through the custom template tag to obtain the verification rule corresponding to the username "username" as rule1, and the verification rule corresponding to the password "password" as rule2.
在一个实施方式中,每个表单字段对应的校验规则由开发人员在前期开发时预先嵌入到每个表单字段的页面标签属性,即每个表单字段对应的页面标签的属性中。其中,页面标签是指dom标签或称为HTML标签。表单字段对应的页面标签可以包括但不限于<input>、<select>。In one embodiment, the verification rule corresponding to each form field is pre-embedded in the page label attribute of each form field by the developer in the early stage of development, that is, the attribute of the page label corresponding to each form field. Among them, page tags refer to dom tags or HTML tags. The page tags corresponding to the form fields can include but are not limited to <input> and <select>.
其中,服务器通过该表单页面中的自定义模板标签对该表单页面进行解析,得到该表单页面对应的表单数据校验规则的步骤,具体是服务器通过该表单页面中的自定义模板标签对该表单页面中每个表单字段的页面标签进行解析,得到预先嵌于每个表单字段的页面标签对应页面标签属性中的校验规则。Among them, the server parses the form page through the custom template tag in the form page, and obtains the step of the form data verification rule corresponding to the form page. Specifically, the server uses the custom template tag in the form page for the form The page label of each form field in the page is parsed to obtain the verification rule in the page label corresponding to the page label attribute of the page label embedded in each form field in advance.
服务器在确定了表单数据校验规则后,即根据该表单数据校验规则生成表单数据校验文件,其中,表单数据校验规则包括的校验规则与该表单数据校验文件包括的校验规则相同,这样可以统一服务器和用户终端校验表单数据所采用的校验规则,从而避免前后台校验结果不同的情况出现。After the server determines the form data verification rule, it generates a form data verification file according to the form data verification rule, where the verification rule included in the form data verification rule and the verification rule included in the form data verification file In the same way, the verification rules used by the server and the user terminal to verify the form data can be unified, thereby avoiding the situation where the front-end and back-end verification results are different.
在一个实施方式中,服务器根据表单数据校验规则生成表单数据校验文件的步骤,具体是服务器根据该表单页面中每个表单字段对应的校验规则生成表单数据校验文件。具体地,该表单数据校验文件是JavaScript文件,嵌于该表单页面中。In one embodiment, the server generates the form data verification file according to the form data verification rule. Specifically, the server generates the form data verification file according to the verification rule corresponding to each form field in the form page. Specifically, the form data verification file is a JavaScript file, which is embedded in the form page.
步骤S30:用户终端获得表单页面和表单数据校验文件后,展示该表单页面,在检测到用户通过该表单页面下发的表单数据提交指令时,使用该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验,在该表单数据通过校验后,向服务器发送与该表单数据关联的表单数据提交请求。Step S30: After the user terminal obtains the form page and the form data verification file, the form page is displayed, and when the form data submission instruction issued by the user through the form page is detected, the form data verification file is used to submit the form data The form data associated with the instruction is verified, and after the form data passes the verification, a form data submission request associated with the form data is sent to the server.
在本实施例中,当用户终端从服务器获得表单页面之后,会开始加载表单页面中的HTML代码,进而向用户展示该表单页面。用户可以在表单页面上的表单字段中输入表单字段数据,比如在用户名字段的文本框(表单字段)中输入用户名信息。In this embodiment, after the user terminal obtains the form page from the server, it will start to load the HTML code in the form page, and then display the form page to the user. The user can enter the form field data in the form field on the form page, for example, enter the user name information in the text box (form field) of the user name field.
当用户完成表单字段数据的输入,并向用户终端下发表单数据提交指令(比如,用户可以通过页面中的提交按钮下发该指令)时,获取表单数据提交指令关联的表单数据,之后通过该表单数据校验文件对该表单数据进行校验。其中,表单数据包括至少一个表单字段数据,该表单字段数据是用户针对该表单页面中的表单字段输入的数据,即用户在表单字段上输入的数据。需要说明的是,在一些场景中,用户需要填写完表单页面中的所有表单字段才能提交,而另一些场景中,允许用户只填写表单页面中部分表单字段(比如,用户只填写必填的表单字段,而不填写非必填的表单字段)即可提交,因此表单数据包括的表单字段数据可能是表单页面上所有表单字段对应的表单字段数据,也可能是表单页面上部分表单字段对应的表单字段数据。When the user completes the input of form field data and issues an order data submission instruction to the user terminal (for example, the user can issue the instruction through the submit button on the page), obtain the form data associated with the form data submission instruction, and then pass the The form data verification file verifies the form data. The form data includes at least one form field data, and the form field data is data input by the user for the form field in the form page, that is, the data input by the user on the form field. It should be noted that in some scenarios, the user needs to fill in all the form fields on the form page to submit, while in other scenarios, the user is allowed to fill in only some form fields in the form page (for example, the user only fills in the required form Field without filling in non-required form fields), so the form field data included in the form data may be the form field data corresponding to all the form fields on the form page, or the form corresponding to some form fields on the form page Field data.
用户终端通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验的步骤,包括:用户终端获取该表单数据提交指令关联的表单数据;通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验。The step of verifying the form data associated with the form data submission instruction by the user terminal through the form data verification file includes: obtaining the form data associated with the form data submission instruction by the user terminal; and verifying the form through the form data verification file All form field data in the data is verified.
其中,用户终端通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验时,具体是从该表单数据校验文件中提取出该表单数据中各个表单字段数据对应的校验规则,然后再使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。Wherein, when the user terminal verifies all form field data in the form data through the form data verification file, it specifically extracts the verification rules corresponding to each form field data in the form data from the form data verification file , And then verify the data of each form field using the verification rules corresponding to the extracted data of each form field.
步骤S40:服务器接收该表单数据提交请求,获取该表单数据校验规则,根据该表单数据校验规则对该表单数据提交请求关联的该表单数据进行校验。Step S40: The server receives the form data submission request, obtains the form data verification rule, and verifies the form data associated with the form data submission request according to the form data verification rule.
在本实施例中,当用户终端对表单数据进行校验,并且校验通过后,会将表单数据提交给服务器,服务器在接收到该表单数据后,会对该表单数据再一次进行校验。其中,服务器会获取与该表单数据对应的表单数据校验规则,然后根据该表单数据校验规则对该表单数据进行校验。具体地,服务器从该表单数据校验规则中提取该表单数据中各个表单字段数据对应的校验规则,之后使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。In this embodiment, when the user terminal verifies the form data, and after the verification is passed, the form data is submitted to the server, and the server will verify the form data again after receiving the form data. Among them, the server obtains the form data verification rule corresponding to the form data, and then verifies the form data according to the form data verification rule. Specifically, the server extracts the verification rule corresponding to each form field data in the form data from the form data verification rule, and then uses the verification rule corresponding to each extracted form field data to verify each form field data .
在一个实施方式中,服务器在确定出表单页面对应的表单数据校验规则之后,可以将该表单数据校验规则存入缓存。相应地,服务器在接收到该表单数据提交请求后需要获取表单数据校验规则时,可以从缓存中获取该表单数据校验规则。In one embodiment, after determining the form data verification rule corresponding to the form page, the server may store the form data verification rule in the cache. Correspondingly, when the server needs to obtain the form data verification rule after receiving the form data submission request, it can obtain the form data verification rule from the cache.
实施例二Example two
基于与实施例一相同的发明构思,本发明一个实施例提供了一种表单数据校验方法,下面以该方法应用于上述表单数据校验系统中的服务器为例进行说明。如图3所示,该方法包括以下步骤:Based on the same inventive concept as the first embodiment, an embodiment of the present invention provides a form data verification method. The following is an example of applying the method to the server in the above form data verification system. As shown in Figure 3, the method includes the following steps:
步骤S110:接收用户终端的表单获取请求,生成与该表单获取请求对应的表单页面。Step S110: Receive a form acquisition request from the user terminal, and generate a form page corresponding to the form acquisition request.
步骤S120:确定该表单页面对应的表单数据校验规则,根据该表单数据校验规则生成表单数据校验文件。Step S120: Determine the form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule.
步骤S130:将该表单页面和该表单数据校验文件发送给用户终端,以使用户终端展示该表单页面,并在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验。Step S130: Send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when detecting the form data submission instruction issued by the user through the form page, pass the form data The verification file verifies the form data associated with the form data submission instruction.
步骤S140:接收用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求,获取该表单数据校验规则,根据该表单数据校验规则对该表单数据进行校验。Step S140: Receive the form data submission request associated with the form data sent by the user terminal after the form data passes the verification, obtain the form data verification rule, and verify the form data according to the form data verification rule.
本实施例能够减少开发人员在实现对表单数据进行验证的功能时所需要编写的代码量,并且能让后台即服务器能够使用复杂的校验方式对表单数据进行校验。此外,由于表单数据校验文件是根据表单数据校验规则生成的,所以前后台对表单数据进行校验所采用的校验规则是一致的,因而不会出现前后台校验结果不一致的情况。This embodiment can reduce the amount of code that developers need to write when realizing the function of verifying form data, and enable the backend, that is, the server, to verify the form data using a complex verification method. In addition, since the form data verification file is generated according to the form data verification rules, the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
在一个实施方式中,该表单页面包括至少一个表单字段;确定该表单页面对应的表单数据校验规则,包括:通过该表单页面中的自定义模板标签对该表单页面进行解析,得到该表单页面对应的表单数据校验规则,该表单数据校验规则包括该表单页面中每个表单字段对应的校验规则。In one embodiment, the form page includes at least one form field; determining the form data verification rule corresponding to the form page includes: parsing the form page through a custom template tag in the form page to obtain the form page Corresponding form data verification rules, the form data verification rules include verification rules corresponding to each form field in the form page.
在一个实施方式中,每个表单字段对应的校验规则预先嵌于该每个表单字段的页面标签属性中。通过该表单页面中的自定义模板标签对该表单页面进行解析,得到该表单页面对应的表单数据校验规则,包括:通过该表单页面中的自定义模板标签对该表单页面中每个表单字段的页面标签进行解析,得到预先嵌于每个表单字段的页面标签对应页面标签属性中的校验规则。In one embodiment, the verification rule corresponding to each form field is embedded in the page label attribute of each form field in advance. The form page is parsed through the custom template tag in the form page to obtain the form data verification rules corresponding to the form page, including: through the custom template tag in the form page, each form field in the form page Parse the page tags of each form field to obtain the verification rules in the page tag corresponding to the page tag attributes pre-embedded in each form field.
在一个实施方式中,表单字段对应的校验规则用于校验该表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施方式中,该表单数据包括至少一个表单字段数据,该表单字段数据是用户针对该表单页面中的表单字段输入的数据;该接收该用户终端在该表单数据通过校验后发送的与该表单数据关联的表单数据提交请求,包括:接收该用户终端发送的表单数据提交请求,该表单数据提交请求是该用户终端获取该表单数据提交指令关联的表单数据,通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验并在该表单数据通过校验后发送的。In one embodiment, the form data includes at least one form field data, the form field data is data input by the user for the form field in the form page; the receiving and sending of the user terminal after the form data passes the verification The form data submission request associated with the form data includes: receiving a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and verifies the file through the form data All form field data in the form data is verified and sent after the form data passes the verification.
在一个实施方式中,表单数据提交请求是用户终端获取该表单数据提交指令关联的表单数据,从该表单数据校验文件中提取该表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验并在该表单数据通过校验后发送的;In one embodiment, the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, extracts the verification rule corresponding to each form field data in the form data from the form data verification file, and uses the extracted to The verification rules corresponding to each form field data in the form field data are verified and sent after the form data passes the verification;
在一个实施方式中,根据该表单数据校验规则对该表单数据进行校验,包括:从该表单数据校验规则中提取该表单数据中各个表单字段数据对应的校验规则;使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。In one embodiment, verifying the form data according to the form data verification rule includes: extracting the verification rule corresponding to each form field data in the form data from the form data verification rule; using the extracted form data The verification rule corresponding to the data of each form field verifies the data of each form field.
在一个实施方式中,表单数据校验规则包括的校验规则与表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施方式中,确定该表单页面对应的表单数据校验规则之后,包括:将该表单数据校验规则存入缓存;获取该表单数据校验规则,包括:从缓存中获取该表单数据校验规则。In one embodiment, after determining the form data verification rule corresponding to the form page, it includes: storing the form data verification rule in a cache; obtaining the form data verification rule includes: obtaining the form data verification rule from the cache. Inspection rules.
在一个实施方式中,根据该表单数据校验规则生成表单数据校验文件,包括:根据该表单页面中每个表单字段对应的校验规则生成表单数据校验文件,该表单数据校验文件是JavaScript文件。In one embodiment, generating the form data verification file according to the form data verification rule includes: generating the form data verification file according to the verification rule corresponding to each form field in the form page, and the form data verification file is JavaScript files.
本实施例是基于与实施例一相同的发明构思提供的,因此关于本实施例提供的表单数据校验方法的具体限定可以参见实施例一中对于服务器与用户终端之间交互过程的限定,在此不再赘述。This embodiment is provided based on the same inventive concept as the first embodiment. Therefore, for the specific definition of the form data verification method provided in this embodiment, please refer to the definition of the interaction process between the server and the user terminal in the first embodiment. This will not be repeated here.
实施例三Example three
本发明的一个实施例提供了一种表单数据校验方法,下面以该方法应用于上述表单数据校验系统中的用户终端为例进行说明。如图4所示,该方法包括以下步骤:An embodiment of the present invention provides a method for verifying form data, and the method is applied to a user terminal in the foregoing form data verification system as an example for description. As shown in Figure 4, the method includes the following steps:
步骤S210:向服务器发送表单获取请求以获得表单页面和表单数据校验文件,该表单页面是服务器接收到该表单获取请求后生成的页面,该表单数据校验文件是服务器确定该表单页面对应的表单数据校验规则,并根据该表单数据校验规则生成的文件。Step S210: Send a form acquisition request to the server to obtain a form page and a form data verification file. The form page is a page generated after the server receives the form acquisition request. The form data verification file is determined by the server to correspond to the form page Form data verification rules, and files generated according to the form data verification rules.
步骤S220:展示该表单页面。Step S220: Display the form page.
步骤S230:在检测到用户通过该表单页面下发的表单数据提交指令时,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验。Step S230: When the form data submission instruction issued by the user through the form page is detected, the form data associated with the form data submission instruction is verified through the form data verification file.
步骤S240:在该表单数据通过校验后,向服务器发送与该表单数据关联的表单数据提交请求,该表单数据提交请求用于指示服务器获取该表单数据校验规则,并根据该表单数据校验规则对该表单数据进行校验。Step S240: After the form data has passed the verification, a form data submission request associated with the form data is sent to the server, and the form data submission request is used to instruct the server to obtain the form data verification rule and verify according to the form data The rule checks the form data.
本实施例能够减少开发人员在实现对表单数据进行验证的功能时所需要编写的代码量,并且能让后台即服务器能够使用复杂的校验方式对表单数据进行校验。此外,由于表单数据校验文件是根据表单数据校验规则生成的,所以前后台对表单数据进行校验所采用的校验规则是一致的,因而不会出现前后台校验结果不一致的情况。This embodiment can reduce the amount of code that developers need to write when realizing the function of verifying form data, and enable the backend, that is, the server, to verify the form data using a complex verification method. In addition, since the form data verification file is generated according to the form data verification rules, the verification rules used by the front-end and back-end to verify the form data are consistent, so there will be no inconsistent front-end and back-end verification results.
在一个实施方式中,通过该表单数据校验文件对该表单数据提交指令关联的表单数据进行校验,包括:In one embodiment, verifying the form data associated with the form data submission instruction through the form data verification file includes:
获取该表单数据提交指令关联的表单数据,该表单数据包括至少一个表单字段数据,该表单字段数据是用户针对该表单页面中的表单字段输入的数据;Acquiring form data associated with the form data submission instruction, the form data including at least one form field data, and the form field data is data input by the user for the form field in the form page;
通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验;Verify all form field data in the form data through the form data verification file;
在一个实施方式中,通过该表单数据校验文件对该表单数据中所有表单字段数据进行校验,包括:In one embodiment, verifying all form field data in the form data through the form data verification file includes:
从该表单数据校验文件中提取该表单数据中各个表单字段数据对应的校验规则;Extract the verification rule corresponding to each form field data in the form data from the form data verification file;
使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验。Use the verification rules corresponding to the extracted form field data to verify each form field data.
在一个实施方式中,该表单页面包括至少一个表单字段,该表单数据校验规则包括该服务器通过该表单页面中的自定义模板标签对该表单页面进行解析而获得的该表单页面中每个该表单字段对应的校验规则。In one embodiment, the form page includes at least one form field, and the form data verification rule includes each of the form pages obtained by the server by parsing the form page through a custom template tag in the form page. The verification rule corresponding to the form field.
在一个实施方式中,该表单数据校验规则包括的每个表单字段对应的校验规则预先嵌于该每个表单字段的页面标签属性中,是该服务端通过该表单页面中的自定义模板标签对该表单页面中每个表单字段的页面标签进行解析而得到的。In one embodiment, the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server uses a custom template in the form page. The label is obtained by parsing the page label of each form field in the form page.
在一个实施方式中,该表单数据提交请求用于指示该服务器获取该表单数据校验规则,从该表单数据校验规则中提取该表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对该各个表单字段数据进行校验;In one embodiment, the form data submission request is used to instruct the server to obtain the form data verification rule, extract the verification rule corresponding to each form field data in the form data from the form data verification rule, and use the extracted to The verification rules corresponding to the data of each form field in, verify the data of each form field;
在一个实施方式中,该表单字段对应的校验规则用于校验该表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施方式中,该表单数据校验规则包括的校验规则与该表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施方式中,该表单数据校验文件是JavaScript文件。In one embodiment, the form data verification file is a JavaScript file.
本实施例是基于与实施例一相同的发明构思提供的,因此关于本实施例提供的表单数据校验方法的具体限定可以参见实施例一中对于服务器与用户终端之间交互过程的限定,在此不再赘述。This embodiment is provided based on the same inventive concept as the first embodiment. Therefore, for the specific definition of the form data verification method provided in this embodiment, please refer to the definition of the interaction process between the server and the user terminal in the first embodiment. This will not be repeated here.
实施例四Embodiment four
基于与实施例二相同的发明构思,本发明的一个实施例提供了一种服务器,如图5所示,该服务器包括以下模块:表单页面生成模块110,用于接收用户终端的表单获取请求,生成与所述表单获取请求对应的表单页面;校验文件生成模块120,用于确定所述表单页面对应的表单数据校验规则,根据所述表单数据校验规则生成表单数据校验文件;发送模块130,用于将所述表单页面和所述表单数据校验文件发送给所述用户终端,以使所述用户终端展示所述表单页面,并在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;校验模块140,用于接收所述用户终端在所述表单数据通过校验后发送的与所述表单数据关联的表单数据提交请求,获取所述表单数据校验规则,根据所述表单数据校验规则对所述表单数据进行校验。Based on the same inventive concept as the second embodiment, one embodiment of the present invention provides a server, as shown in FIG. 5, the server includes the following modules: a form page generation module 110, which is used to receive a form acquisition request from a user terminal, Generate a form page corresponding to the form acquisition request; a verification file generating module 120, configured to determine a form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule; and The module 130 is configured to send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when it is detected that the user issued the form page through the form page When a form data submission instruction is used, the form data associated with the form data submission instruction is verified through the form data verification file; the verification module 140 is configured to receive the user terminal after the form data has passed verification The sent form data submission request associated with the form data obtains the form data verification rule, and verifies the form data according to the form data verification rule.
在一个实施方式中,所述表单页面包括至少一个表单字段;In one embodiment, the form page includes at least one form field;
校验文件生成模块,包括:解析子模块,用于通过所述表单页面中的自定义模板标签对所述表单页面进行解析,得到所述表单页面对应的表单数据校验规则,所述表单数据校验规则包括所述表单页面中每个表单字段对应的校验规则。The verification file generation module includes: a parsing sub-module for parsing the form page through a custom template tag in the form page to obtain the form data verification rule corresponding to the form page, the form data The verification rule includes a verification rule corresponding to each form field in the form page.
在一个实施方式中,所述每个表单字段对应的校验规则预先嵌于所述每个表单字段的页面标签属性中;In one embodiment, the verification rule corresponding to each form field is embedded in the page label attribute of each form field in advance;
所述解析子模块,还用于通过所述表单页面中的自定义模板标签对所述表单页面中每个表单字段的页面标签进行解析,得到预先嵌于所述每个表单字段的页面标签对应页面标签属性中的校验规则。The parsing sub-module is also used to parse the page label of each form field in the form page through the custom template label in the form page to obtain the corresponding page label embedded in each form field in advance Validation rules in page label properties.
在一个实施方式中,所述表单字段对应的校验规则用于校验所述表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施方式中,所述表单数据包括至少一个表单字段数据,所述表单字段数据是用户针对所述表单页面中的表单字段输入的数据;In one embodiment, the form data includes at least one form field data, and the form field data is data input by a user for a form field in the form page;
校验模块,包括:提交请求接收子模块,用于接收所述用户终端发送的表单数据提交请求,所述表单数据提交请求是所述用户终端获取所述表单数据提交指令关联的表单数据,通过所述表单数据校验文件对所述表单数据中所有表单字段数据进行校验并在所述表单数据通过校验后发送的。The verification module includes: a submission request receiving sub-module, configured to receive a form data submission request sent by the user terminal, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction through The form data verification file verifies all form field data in the form data and is sent after the form data passes the verification.
在一个实施方式中,所述表单数据提交请求是所述用户终端获取所述表单数据提交指令关联的表单数据,从所述表单数据校验文件中提取所述表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验并在所述表单数据通过校验后发送的。In one embodiment, the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and extracts data corresponding to each form field in the form data from the form data verification file The verification rule is used to verify the respective form field data using the verification rule corresponding to each extracted form field data and is sent after the form data passes the verification.
在一个实施方式中,校验模块,包括:规则提取子模块,用于从所述表单数据校验规则中提取所述表单数据中各个表单字段数据对应的校验规则;校验子模块,用于使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验;In one embodiment, the verification module includes: a rule extraction sub-module, which is used to extract a verification rule corresponding to each form field data in the form data from the form data verification rule; the verification sub-module uses To verify the data of each form field using a verification rule corresponding to the extracted data of each form field;
在一个实施方式中,所述表单数据校验规则包括的校验规则与所述表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施方式中,服务器还包括存储模块;该存储模块,用于在确定所述表单页面对应的表单数据校验规则之后,将所述表单数据校验规则存入缓存。相应地,校验模块在用于获取所述表单数据校验规则时,具体用于从缓存中获取所述表单数据校验规则。In one embodiment, the server further includes a storage module; the storage module is configured to store the form data verification rule in a cache after the form data verification rule corresponding to the form page is determined. Correspondingly, when the verification module is used to obtain the form data verification rule, it is specifically used to obtain the form data verification rule from the cache.
在一个实施方式中,校验文件生成模块,还用于根据所述表单页面中每个表单字段对应的校验规则生成表单数据校验文件,所述表单数据校验文件是JavaScript文件。In one embodiment, the verification file generation module is further configured to generate a form data verification file according to a verification rule corresponding to each form field in the form page, and the form data verification file is a JavaScript file.
关于服务器的具体限定可以参见上文中对于应用于服务器的表单数据校验方法的限定,在此不再赘述。上述服务器中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the server, please refer to the above limitation of the form data verification method applied to the server, which will not be repeated here. Each module in the above-mentioned server can be implemented in whole or in part by software, hardware, and a combination thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
实施例五Embodiment five
基于与实施例三相同的发明构思,本发明的一个实施例提供了一种用户终端,如图6所示,该用户终端包括以下模块:获取请求发送模块210,用于向服务器发送表单获取请求以获得表单页面和表单数据校验文件,所述表单页面是所述服务器接收到所述表单获取请求后生成的页面,所述表单数据校验文件是所述服务器确定所述表单页面对应的表单数据校验规则,并根据所述表单数据校验规则生成的文件;展示模块220,用于展示所述表单页面;校验模块230,用于在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;提交请求发送模块240,用于在所述表单数据通过校验后,向所述服务器发送与所述表单数据关联的表单数据提交请求,所述表单数据提交请求用于指示所述服务器获取所述表单数据校验规则,并根据所述表单数据校验规则对所述表单数据进行校验。Based on the same inventive concept as the third embodiment, an embodiment of the present invention provides a user terminal. As shown in FIG. 6, the user terminal includes the following modules: an acquisition request sending module 210, which is used to send a form acquisition request to a server To obtain a form page and a form data verification file, the form page is a page generated after the server receives the form acquisition request, and the form data verification file is a form that the server determines that the form page corresponds to Data verification rules, and files generated according to the form data verification rules; display module 220, used to display the form page; verification module 230, used to detect the form issued by the user through the form page When submitting a data instruction, verify the form data associated with the form data submission instruction through the form data verification file; the submission request sending module 240 is configured to send the form data to the server after the form data has passed the verification. Send a form data submission request associated with the form data, where the form data submission request is used to instruct the server to obtain the form data verification rule, and to verify the form data according to the form data verification rule Test.
在一个实施方式中,校验模块,包括:表单数据获取子模块,用于获取所述表单数据提交指令关联的表单数据,所述表单数据包括至少一个表单字段数据,所述表单字段数据是用户针对所述表单页面中的表单字段输入的数据;校验子模块,用于通过所述表单数据校验文件对所述表单数据中所有表单字段数据进行校验;In one embodiment, the verification module includes: a form data acquisition sub-module for acquiring form data associated with the form data submission instruction, the form data includes at least one form field data, and the form field data is a user For the data entered in the form fields in the form page; a verification sub-module for verifying all form field data in the form data through the form data verification file;
在一个实施方式中,校验子模块,包括:规则提取单元,用于从所述表单数据校验文件中提取所述表单数据中各个表单字段数据对应的校验规则;校验单元,用于使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验。In one embodiment, the verification sub-module includes: a rule extraction unit for extracting a verification rule corresponding to each form field data in the form data from the form data verification file; a verification unit for The verification rules corresponding to the extracted form field data are used to verify the respective form field data.
在一个实施方式中,所述表单页面包括至少一个表单字段,所述表单数据校验规则包括所述服务器通过所述表单页面中的自定义模板标签对所述表单页面进行解析而获得的所述表单页面中每个所述表单字段对应的校验规则。In one embodiment, the form page includes at least one form field, and the form data verification rule includes the information obtained by the server from parsing the form page through a custom template tag in the form page. The verification rule corresponding to each of the form fields in the form page.
在一个实施方式中,所述表单数据校验规则包括的每个表单字段对应的校验规则预先嵌于所述每个表单字段的页面标签属性中,是所述服务端通过所述表单页面中的自定义模板标签对所述表单页面中每个表单字段的页面标签进行解析而得到的。In one embodiment, the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field, and the server passes through the form page The custom template tag is obtained by parsing the page tag of each form field in the form page.
在一个实施方式中,所述表单数据提交请求用于指示所述服务器获取所述表单数据校验规则,从所述表单数据校验规则中提取所述表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验。In one embodiment, the form data submission request is used to instruct the server to obtain the form data verification rule, and extract the verification corresponding to each form field data in the form data from the form data verification rule Rule, using the extracted verification rules corresponding to the extracted form field data to verify the respective form field data.
在一个实施方式中,所述表单字段对应的校验规则用于校验所述表单字段对应的表单字段数据。In one embodiment, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
在一个实施方式中,所述表单数据校验规则包括的校验规则与所述表单数据校验文件包括的校验规则相同。In one embodiment, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file.
在一个实施方式中,所述表单数据校验文件是JavaScript文件。In one embodiment, the form data verification file is a JavaScript file.
关于用户终端的具体限定可以参见上文中对于应用于用户终端的表单数据校验方法的限定,在此不再赘述。上述用户终端中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the user terminal, please refer to the above limitation on the form data verification method applied to the user terminal, which will not be repeated here. Each module in the above-mentioned user terminal may be implemented in whole or in part by software, hardware, and a combination thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
实施例六Example Six
本发明的一个实施例提供了一种计算机设备,其内部结构图可以如图7所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储表单数据校验规则等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。An embodiment of the present invention provides a computer device, and its internal structure diagram may be as shown in FIG. 7. The computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer equipment is used to store data such as form data verification rules. The network interface of the computer device is used to communicate with an external terminal through a network connection.
在一个实施方式中,该处理器执行该计算机程序时实现实施例二或实施例三中描述的表单数据校验方法的步骤。In one embodiment, the processor implements the steps of the form data verification method described in Embodiment 2 or Embodiment 3 when the processor executes the computer program.
本领域技术人员可以理解,图7中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 7 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
实施例七Example Seven
本发明的一个实施例提供了一种计算机可读存储介质,其上存储有计算机程序。An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored.
在一个实施方式中,该计算机程序被处理器执行时实现实施例二或实施例三中描述的表单数据校验方法的步骤。In one embodiment, when the computer program is executed by the processor, the steps of the form data verification method described in the second or third embodiment are implemented.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation manners of the present application, and their descriptions are more specific and detailed, but they should not be understood as limiting the scope of invention patents. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can be made, and these all fall within the protection scope of this application. Therefore, the scope of protection of the patent of this application shall be subject to the appended claims.

Claims (10)

  1. 一种表单数据校验方法,其特征在于,所述方法包括:A method for verifying form data, characterized in that the method includes:
    接收用户终端的表单获取请求,生成与所述表单获取请求对应的表单页面;Receiving a form obtaining request from the user terminal, and generating a form page corresponding to the form obtaining request;
    确定所述表单页面对应的表单数据校验规则,根据所述表单数据校验规则生成表单数据校验文件;Determine the form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule;
    将所述表单页面和所述表单数据校验文件发送给所述用户终端,以使所述用户终端展示所述表单页面,并在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;Sending the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when detecting the form data submission instruction issued by the user through the form page , Verifying the form data associated with the form data submission instruction through the form data verification file;
    接收所述用户终端在所述表单数据通过校验后发送的与所述表单数据关联的表单数据提交请求,获取所述表单数据校验规则,根据所述表单数据校验规则对所述表单数据进行校验。Receive the form data submission request associated with the form data sent by the user terminal after the form data has passed the verification, obtain the form data verification rule, and compare the form data according to the form data verification rule Perform verification.
  2. 如权利要求1所述的表单数据校验方法,其特征在于,The form data verification method according to claim 1, wherein:
    所述表单页面包括至少一个表单字段;The form page includes at least one form field;
    所述确定所述表单页面对应的表单数据校验规则,包括:The determining the form data verification rule corresponding to the form page includes:
    通过所述表单页面中的自定义模板标签对所述表单页面进行解析,得到所述表单页面对应的表单数据校验规则,所述表单数据校验规则包括所述表单页面中每个表单字段对应的校验规则;The form page is parsed through the custom template tag in the form page to obtain the form data verification rule corresponding to the form page. The form data verification rule includes the correspondence of each form field in the form page The verification rules;
    优选地,所述每个表单字段对应的校验规则预先嵌于所述每个表单字段的页面标签属性中;Preferably, the verification rule corresponding to each form field is embedded in the page label attribute of each form field in advance;
    所述通过所述表单页面中的自定义模板标签对所述表单页面进行解析,得到所述表单页面对应的表单数据校验规则,包括:The parsing of the form page through the custom template tag in the form page to obtain the form data verification rule corresponding to the form page includes:
    通过所述表单页面中的自定义模板标签对所述表单页面中每个表单字段的页面标签进行解析,得到预先嵌于所述每个表单字段的页面标签对应页面标签属性中的校验规则;Parse the page label of each form field in the form page through the custom template label in the form page to obtain the verification rule in the page label corresponding to the page label attribute of the page label pre-embedded in each form field;
    优选地,所述表单字段对应的校验规则用于校验所述表单字段对应的表单字段数据。Preferably, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field.
  3. 如权利要求1-2任一项所述的表单数据校验方法,其特征在于,The method for verifying form data according to any one of claims 1-2, wherein:
    所述表单数据包括至少一个表单字段数据,所述表单字段数据是用户针对所述表单页面中的表单字段输入的数据;The form data includes at least one form field data, and the form field data is data input by a user for a form field in the form page;
    所述接收所述用户终端在所述表单数据通过校验后发送的与所述表单数据关联的表单数据提交请求,包括:The receiving the form data submission request associated with the form data sent by the user terminal after the form data passes the verification includes:
    接收所述用户终端发送的表单数据提交请求,所述表单数据提交请求是所述用户终端获取所述表单数据提交指令关联的表单数据,通过所述表单数据校验文件对所述表单数据中所有表单字段数据进行校验并在所述表单数据通过校验后发送的;A form data submission request sent by the user terminal is received, where the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and compares all the form data in the form data through the form data verification file The form field data is verified and sent after the form data passes the verification;
    优选地,所述表单数据提交请求是所述用户终端获取所述表单数据提交指令关联的表单数据,从所述表单数据校验文件中提取所述表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验并在所述表单数据通过校验后发送的;Preferably, the form data submission request is that the user terminal obtains the form data associated with the form data submission instruction, and extracts the verification rule corresponding to each form field data in the form data from the form data verification file , Verifying each form field data using a verification rule corresponding to each extracted form field data and sending it after the form data passes the verification;
    优选地,所述根据所述表单数据校验规则对所述表单数据进行校验,包括:Preferably, the verification of the form data according to the form data verification rule includes:
    从所述表单数据校验规则中提取所述表单数据中各个表单字段数据对应的校验规则;Extracting the verification rule corresponding to each form field data in the form data from the form data verification rule;
    使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验;Verify the data of each form field by using the verification rule corresponding to the extracted data of each form field;
    优选地,所述表单数据校验规则包括的校验规则与所述表单数据校验文件包括的校验规则相同;Preferably, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file;
    优选地,所述确定所述表单页面对应的表单数据校验规则之后,包括:Preferably, after determining the form data verification rule corresponding to the form page, the method includes:
    将所述表单数据校验规则存入缓存;Store the form data verification rule in a cache;
    所述获取所述表单数据校验规则,包括:The obtaining the form data verification rule includes:
    从缓存中获取所述表单数据校验规则。Obtain the form data verification rule from the cache.
  4. 如权利要求1-3任一项所述的表单数据校验方法,其特征在于, The form data verification method according to any one of claims 1-3, wherein:
    所述根据所述表单数据校验规则生成表单数据校验文件,包括:The generating a form data verification file according to the form data verification rule includes:
    根据所述表单页面中每个表单字段对应的校验规则生成表单数据校验文件,所述表单数据校验文件是JavaScript文件。A form data verification file is generated according to a verification rule corresponding to each form field in the form page, and the form data verification file is a JavaScript file.
  5. 一种表单数据校验方法,其特征在于,所述方法包括:A method for verifying form data, characterized in that the method includes:
    向服务器发送表单获取请求以获得表单页面和表单数据校验文件,所述表单页面是所述服务器接收到所述表单获取请求后生成的页面,所述表单数据校验文件是所述服务器确定所述表单页面对应的表单数据校验规则,并根据所述表单数据校验规则生成的文件;Send a form acquisition request to the server to obtain a form page and a form data verification file, where the form page is a page generated after the server receives the form acquisition request, and the form data verification file is determined by the server The form data verification rule corresponding to the form page, and the file generated according to the form data verification rule;
    展示所述表单页面;Display the form page;
    在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;When the form data submission instruction issued by the user through the form page is detected, verify the form data associated with the form data submission instruction through the form data verification file;
    在所述表单数据通过校验后,向所述服务器发送与所述表单数据关联的表单数据提交请求,所述表单数据提交请求用于指示所述服务器获取所述表单数据校验规则,并根据所述表单数据校验规则对所述表单数据进行校验。After the form data has passed the verification, a form data submission request associated with the form data is sent to the server, the form data submission request is used to instruct the server to obtain the form data verification rule, and according to The form data verification rule verifies the form data.
  6. 如权利要求5所述的表单数据校验方法,其特征在于,The form data verification method according to claim 5, wherein:
    所述通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验,包括:The verifying the form data associated with the form data submission instruction through the form data verification file includes:
    获取所述表单数据提交指令关联的表单数据,所述表单数据包括至少一个表单字段数据,所述表单字段数据是用户针对所述表单页面中的表单字段输入的数据;Acquiring form data associated with the form data submission instruction, where the form data includes at least one form field data, and the form field data is data input by a user for a form field in the form page;
    通过所述表单数据校验文件对所述表单数据中所有表单字段数据进行校验;Verify all form field data in the form data through the form data verification file;
    优选地,所述通过所述表单数据校验文件对所述表单数据中所有表单字段数据进行校验,包括:Preferably, the verification of all form field data in the form data through the form data verification file includes:
    从所述表单数据校验文件中提取所述表单数据中各个表单字段数据对应的校验规则;Extracting, from the form data verification file, the verification rule corresponding to each form field data in the form data;
    使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验。The verification rules corresponding to the extracted form field data are used to verify the respective form field data.
  7. 如权利要求5或6所述的表单数据校验方法,其特征在于,The form data verification method according to claim 5 or 6, characterized in that:
    所述表单页面包括至少一个表单字段,所述表单数据校验规则包括所述服务器通过所述表单页面中的自定义模板标签对所述表单页面进行解析而获得的所述表单页面中每个所述表单字段对应的校验规则;The form page includes at least one form field, and the form data verification rule includes each of the form pages obtained by the server by parsing the form page through a custom template tag in the form page. Describe the verification rules corresponding to the form fields;
    优选地,所述表单数据校验规则包括的每个表单字段对应的校验规则预先嵌于所述每个表单字段的页面标签属性中,是所述服务端通过所述表单页面中的自定义模板标签对所述表单页面中每个表单字段的页面标签进行解析而得到的;Preferably, the verification rule corresponding to each form field included in the form data verification rule is pre-embedded in the page label attribute of each form field. The template tag is obtained by parsing the page tag of each form field in the form page;
    优选地,所述表单数据提交请求用于指示所述服务器获取所述表单数据校验规则,从所述表单数据校验规则中提取所述表单数据中各个表单字段数据对应的校验规则,使用提取到的各个表单字段数据对应的校验规则对所述各个表单字段数据进行校验;Preferably, the form data submission request is used to instruct the server to obtain the form data verification rule, extract the verification rule corresponding to each form field data in the form data from the form data verification rule, and use The verification rule corresponding to each extracted form field data verifies the various form field data;
    优选地,所述表单字段对应的校验规则用于校验所述表单字段对应的表单字段数据;Preferably, the verification rule corresponding to the form field is used to verify the form field data corresponding to the form field;
    优选地,所述表单数据校验规则包括的校验规则与所述表单数据校验文件包括的校验规则相同;Preferably, the verification rule included in the form data verification rule is the same as the verification rule included in the form data verification file;
    优选地,所述表单数据校验文件是JavaScript文件。Preferably, the form data verification file is a JavaScript file.
  8. 一种服务器,其特征在于,所述服务器包括:A server, characterized in that the server includes:
    表单页面生成模块,用于接收用户终端的表单获取请求,生成与所述表单获取请求对应的表单页面;The form page generation module is used to receive a form acquisition request from the user terminal, and generate a form page corresponding to the form acquisition request;
    校验文件生成模块,用于确定所述表单页面对应的表单数据校验规则,根据所述表单数据校验规则生成表单数据校验文件;A verification file generating module, configured to determine the form data verification rule corresponding to the form page, and generate a form data verification file according to the form data verification rule;
    发送模块,用于将所述表单页面和所述表单数据校验文件发送给所述用户终端,以使所述用户终端展示所述表单页面,并在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;The sending module is configured to send the form page and the form data verification file to the user terminal, so that the user terminal displays the form page, and when it is detected that the user sends the form page through the form page When a form data submission instruction is used, the form data associated with the form data submission instruction is verified through the form data verification file;
    校验模块,用于接收所述用户终端在所述表单数据通过校验后发送的与所述表单数据关联的表单数据提交请求,获取所述表单数据校验规则,根据所述表单数据校验规则对所述表单数据进行校验。The verification module is configured to receive the form data submission request associated with the form data sent by the user terminal after the form data passes the verification, obtain the form data verification rule, and verify according to the form data The rule verifies the form data.
  9. 一种用户终端,其特征在于,所述用户终端包括:A user terminal, characterized in that, the user terminal includes:
    获取请求发送模块,用于向服务器发送表单获取请求以获得表单页面和表单数据校验文件,所述表单页面是所述服务器接收到所述表单获取请求后生成的页面,所述表单数据校验文件是所述服务器确定所述表单页面对应的表单数据校验规则,并根据所述表单数据校验规则生成的文件;An acquisition request sending module, configured to send a form acquisition request to a server to obtain a form page and a form data verification file, where the form page is a page generated after the server receives the form acquisition request, and the form data verification The file is a file that the server determines the form data verification rule corresponding to the form page, and is generated according to the form data verification rule;
    展示模块,用于展示所述表单页面;The display module is used to display the form page;
    校验模块,用于在检测到用户通过所述表单页面下发的表单数据提交指令时,通过所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验;The verification module is configured to verify the form data associated with the form data submission instruction through the form data verification file when the form data submission instruction issued by the user through the form page is detected;
    提交请求发送模块,用于在所述表单数据通过校验后,向所述服务器发送与所述表单数据关联的表单数据提交请求,所述表单数据提交请求用于指示所述服务器获取所述表单数据校验规则,并根据所述表单数据校验规则对所述表单数据进行校验。The submission request sending module is configured to send a form data submission request associated with the form data to the server after the form data passes the verification, and the form data submission request is used to instruct the server to obtain the form Data verification rules, and verify the form data according to the form data verification rules.
  10. 一种表单数据校验系统,其特征在于,所述系统包括用户终端和服务器;A form data verification system, characterized in that the system includes a user terminal and a server;
    所述用户终端向所述服务器发送表单获取请求;The user terminal sends a form acquisition request to the server;
    所述服务器接收所述表单获取请求,生成与所述表单获取请求对应的表单页面,确定所述表单页面对应的表单数据校验规则,根据所述表单数据校验规则生成表单数据校验文件,将所述表单页面和所述表单数据校验文件发送给所述用户终端;The server receives the form acquisition request, generates a form page corresponding to the form acquisition request, determines a form data verification rule corresponding to the form page, and generates a form data verification file according to the form data verification rule, Sending the form page and the form data verification file to the user terminal;
    所述用户终端获得表单页面和表单数据校验文件后,展示所述表单页面,在检测到用户通过所述表单页面下发的表单数据提交指令时,使用所述表单数据校验文件对所述表单数据提交指令关联的表单数据进行校验,在所述表单数据通过校验后,向所述服务器发送与所述表单数据关联的表单数据提交请求;After the user terminal obtains the form page and the form data verification file, the form page is displayed, and when the form data submission instruction issued by the user through the form page is detected, the form data verification file is used to compare the form data The form data associated with the form data submission instruction is verified, and after the form data passes the verification, a form data submission request associated with the form data is sent to the server;
    所述服务器接收所述表单数据提交请求,获取所述表单数据校验规则,根据所述表单数据校验规则对所述表单数据提交请求关联的所述表单数据进行校验。The server receives the form data submission request, obtains the form data verification rule, and verifies the form data associated with the form data submission request according to the form data verification rule.
PCT/CN2021/098730 2020-06-10 2021-06-07 Form data verification method, system, server, and user terminal WO2021249356A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010523593.5A CN111736811A (en) 2020-06-10 2020-06-10 Form data verification method, system, server and user terminal
CN202010523593.5 2020-06-10

Publications (1)

Publication Number Publication Date
WO2021249356A1 true WO2021249356A1 (en) 2021-12-16

Family

ID=72648694

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/098730 WO2021249356A1 (en) 2020-06-10 2021-06-07 Form data verification method, system, server, and user terminal

Country Status (2)

Country Link
CN (1) CN111736811A (en)
WO (1) WO2021249356A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115146322A (en) * 2022-09-01 2022-10-04 杭州安恒信息技术股份有限公司 Data verification method, device and equipment and storage medium
CN115544417A (en) * 2022-10-10 2022-12-30 中电金信软件有限公司 Webpage form verification method and device, electronic equipment and storage medium
CN116633698A (en) * 2023-07-25 2023-08-22 中国电信股份有限公司 Data transmission method, apparatus, computer device, storage medium, and program product

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111736811A (en) * 2020-06-10 2020-10-02 苏宁云计算有限公司 Form data verification method, system, server and user terminal
CN112241370B (en) * 2020-10-21 2023-06-16 网易(杭州)网络有限公司 API interface class checking method, system and device
CN113377417A (en) * 2021-06-29 2021-09-10 中国平安财产保险股份有限公司 Form data checking method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819766A (en) * 2011-06-09 2012-12-12 金蝶软件(中国)有限公司 Method, device and enterprise system for checking forms
US20180046606A1 (en) * 2015-11-20 2018-02-15 Huawei Technologies Co., Ltd. Form Checking Method and Apparatus
CN110569036A (en) * 2019-08-20 2019-12-13 广州华资软件技术有限公司 data verification system and method under front-end and back-end separation architecture
CN111736811A (en) * 2020-06-10 2020-10-02 苏宁云计算有限公司 Form data verification method, system, server and user terminal

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7877681B2 (en) * 2002-12-05 2011-01-25 Borland Software Corporation Automatic context management for web applications with client side code execution

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819766A (en) * 2011-06-09 2012-12-12 金蝶软件(中国)有限公司 Method, device and enterprise system for checking forms
US20180046606A1 (en) * 2015-11-20 2018-02-15 Huawei Technologies Co., Ltd. Form Checking Method and Apparatus
CN110569036A (en) * 2019-08-20 2019-12-13 广州华资软件技术有限公司 data verification system and method under front-end and back-end separation architecture
CN111736811A (en) * 2020-06-10 2020-10-02 苏宁云计算有限公司 Form data verification method, system, server and user terminal

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115146322A (en) * 2022-09-01 2022-10-04 杭州安恒信息技术股份有限公司 Data verification method, device and equipment and storage medium
CN115146322B (en) * 2022-09-01 2022-11-22 杭州安恒信息技术股份有限公司 Data verification method, device and equipment and storage medium
CN115544417A (en) * 2022-10-10 2022-12-30 中电金信软件有限公司 Webpage form verification method and device, electronic equipment and storage medium
CN116633698A (en) * 2023-07-25 2023-08-22 中国电信股份有限公司 Data transmission method, apparatus, computer device, storage medium, and program product
CN116633698B (en) * 2023-07-25 2023-10-31 中国电信股份有限公司 Data transmission method, apparatus, computer device, storage medium, and program product

Also Published As

Publication number Publication date
CN111736811A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
US11561846B2 (en) API notebook tool
WO2021249356A1 (en) Form data verification method, system, server, and user terminal
JP4179553B2 (en) Display control information generation method, computer for generating display control information, and program
US7451393B1 (en) System and method for a page rendering framework
US8156420B2 (en) Form validation with table driven error handling
US20100318894A1 (en) Modifications to Editable Elements of Web Pages Rendered in Word Processor Applications
CN110162408B (en) Data processing method, device, equipment and machine-readable medium
US8799861B2 (en) Performance-testing a system with functional-test software and a transformation-accelerator
US20160224530A1 (en) Mapping stored client data to requested data using metadata
US10705949B2 (en) Evaluation of library test suites using mutation testing
US11010287B1 (en) Field property extraction and field value validation using a validated dataset
US9264507B2 (en) Cross domain communication channel
JP2006260390A (en) Test case generating program and method
JP2013528859A (en) Integration of client application and web page
US20180083849A1 (en) End-to-end tracing providers and session management
US20180341787A1 (en) Method and system to maintain the integrity of a certified document while persisting state in a dynamic form
US11030304B2 (en) Buffer overflow detection based on a synthesis of assertions from templates and k-induction
US10956659B1 (en) System for generating templates from webpages
US10887186B2 (en) Scalable web services execution
US20130061126A1 (en) Secure document creation from potentially unsecure source templates
US20220365921A1 (en) Verifiable Cacheable Calclulations
US7577904B1 (en) Definition and distribution of business rules while enforcing syntactic and semantic validation
CA3089289C (en) System and methods for loading objects from hash chains
US10698794B1 (en) Application container and application service system
US10235146B1 (en) Method and mechanism for composite data service generation and implementation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21822844

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21822844

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 21822844

Country of ref document: EP

Kind code of ref document: A1