Detailed introduction to code sharing for repeated data verification in Form submission under the BootStrap + Mybatis framework

Source: Internet
Author: User
This article mainly introduces how to implement the form submission Data repeat verification function under the BootStrap + Mybatis framework, which is very good and has reference value, for more information about how to use the BootStrap + Mybatis framework to verify data duplication in Form submission, see this article.


Jsp page:



Ace. load_ajax_scripts (scripts, function () {jQuery (function ($) {// verification $ ("# dbc_code_add_form "). validate ({rules: {'versioncode': {required: true, maxlength: 20, remote: {type: "post", dataType: "json", data: {versionCode: function () {return $ ("# versionCode "). val () ;}, oldversionCode: function () {return $ ("# oldversionCode "). val () ;}, url: "$ {base}/admin/road/app/validateversionCode. do "}}, 'versionname': {required: true, maxlength: 40, remote: {type:" post ", dataType:" json ", data: {versionName: function () {return $ ("# versionName "). val () ;}, oldversionName: function () {return $ ("# oldversionName "). val () ;}, url: "$ {base}/admin/road/app/validateversionName. do "}}, 'updatelog ': {required: true, maxlength: 125 }}, messages: {'versioncode': {required:" required ", remote: "duplicate version numbers", maxlength: "Up to 10 characters"}, 'versionname': {required: "required", remote: "duplicate version names", maxlength: "Up to 40 BITs allowed"}, 'updatelog': {required: "required", maxlength: "up to 120 bits allowed "}}});});});

Controller control layer:

@RequestMapping(value="/validateversionCode",method=RequestMethod.POST) @ResponseBody public boolean validateversionCode(@RequestParam("versionCode")String versionCode, @RequestParam("oldversionCode")String oldversionCode){ if(!versionCode.equals(oldversionCode)||StringUtils.isEmpty(oldversionCode)){ boolean isOk = appversionService.validateversionCode(versionCode); return isOk; } return true; }
@RequestMapping(value="/validateversionName",method=RequestMethod.POST) @ResponseBody public boolean validateversionName(@RequestParam("versionName")String versionName, @RequestParam("oldversionName")String oldversionName){ if(!versionName.equals(oldversionName)||StringUtils.isEmpty(oldversionName)){ boolean isOk = appversionService.validateversionName(versionName); return isOk; } return true; }

Service Layer

@Overridepublic boolean validateversionCode(String versionCode){int count = dbcAppVersionMapper.validateversionCode(versionCode);return (count>0)?false:true;}@Overridepublic boolean validateversionName(String versionName){int count = dbcAppVersionMapper.validateversionName(versionName);return (count>0)?false:true;}

Dao Layer

int validateversionCode(@Param("versionCode")String versionCode);int validateversionName(@Param("versionName")String versionName);

Mapper. xml

  Select count (id) from dbc_app_versionwhere VERSION_NAME =#{ versionName}
  Select count (id) from dbc_app_versionwhere VERSION_CODE =#{ versionCode}

The above section details how to share code that implements form submission data duplication verification under the BootStrap + Mybatis framework. For more information, see other related articles in the first PHP community!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.