這篇文章給大家分享的是有關(guān)BootStrap+Mybatis框架下如何實(shí)現(xiàn)表單提交數(shù)據(jù)重復(fù)驗(yàn)證的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
成都創(chuàng)新互聯(lián)是一家專業(yè)提供云南企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、HTML5、小程序制作等業(yè)務(wù)。10年已為云南眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。
效果:
jsp頁(yè)面:
<form class="form-horizontal lui-tj-bd" id="dbc_code_add_form" method="post"> <div class="row"> <div class="col-xs-12"> <!-- PAGE CONTENT BEGINS --> <div class="tabbable"> <div class="space-12"></div> <div class="profile-user-info profile-user-info-striped"> <div class="profile-info-row"> <div class="profile-info-name" > 版本號(hào)<font color="red">*</font></div> <div class="profile-info-value"> <input type="hidden" value="${list.id}" name="id" class="col-xs-12 col-sm-9" /> <input type="hidden" value="${list.versionCode}" id="oldversionCode" name="oldversionCode" class="col-xs-12 col-sm-9" /> <input type="text" value="${list.versionCode}" id="versionCode" name="versionCode" class="col-xs-12 col-sm-9" /> </div> </div> <div class="profile-info-row"> <div class="profile-info-name" > 版本名稱<font color="red">*</font></div> <div class="profile-info-value"> <input type="hidden" value="${list.versionName}" id="oldversionName" name="oldversionName" class="col-xs-12 col-sm-9" /> <input type="text" value="${list.versionName}" id="versionName" name="versionName" class="col-xs-12 col-sm-9"/> </div> </div> <div class="profile-info-row"> <div class="profile-info-name" > 上傳應(yīng)用程序<font color="red">*</font></div> <div class="profile-info-value"> <input type="file" name="file_upload" id="file_upload" /> </div> </div> <div class="profile-info-row "> <div class="profile-info-name"> 下載地址<font color="red">*</font> </div> <div class="profile-info-value"> <span class="editable editable-click"> <input type="text" id="downloadUrl" name="downloadUrl" class="col-xs-12 col-sm-9" readonly="readonly" value="${list.downloadUrl}" /> </span> </div> </div> <div class="profile-info-row"> <div class="profile-info-name" > 更新備注<font color="red">*</font></div> <div class="profile-info-value"> <textarea class="col-sm-9 col-xs-12 " rows="5" id="updateLog" name="updateLog" >${list.updateLog}</textarea> </div> </div> </div> <div class="space-24"></div> <div> <div class=" col-md-offset-2 col-md-9 col-xs-12"> <div class=" col-xs-6"> <button class="btn btn-sm btn-success" type="button" id="saveButton2" onclick="tobaocun()"> <i class="ace-icon fa fa-check "></i>保存 </button> </div> <button class="btn btn-sm btn-purple" type="reset"> <i class="ace-icon fa fa-undo "></i> 重置 </button> </div> </div> </div> </div> </div> </form>
js:
ace.load_ajax_scripts(scripts, function () { jQuery(function ($) { //驗(yàn)證 $("#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: "<font color='#d16e6c'>必填</font>", remote:"<font color='#d16e6c'>版本號(hào)重復(fù)</font>", maxlength:"<font color='#d16e6c'>最大不能超過(guò)10位</font>" }, 'versionName':{ required: "<font color='#d16e6c'>必填</font>", remote:"<font color='#d16e6c'>版本名稱重復(fù)</font>", maxlength:"<font color='#d16e6c'>最大不能超過(guò)40位</font>" }, 'updateLog':{ required: "<font color='#d16e6c'>必填</font>", maxlength:"<font color='#d16e6c'>最大不能超過(guò)120位</font>" } } }); }); });
controller控制層:
@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服務(wù)層
@Override public boolean validateversionCode(String versionCode){ int count = dbcAppVersionMapper.validateversionCode(versionCode); return (count>0)?false:true; } @Override public boolean validateversionName(String versionName){ int count = dbcAppVersionMapper.validateversionName(versionName); return (count>0)?false:true; }
dao 層
int validateversionCode(@Param("versionCode")String versionCode); int validateversionName(@Param("versionName")String versionName);
mapper.xml
<!-- APP版本名稱驗(yàn)證--> <select id="validateversionName" resultType="java.lang.Integer"> select count(id) from dbc_app_version where VERSION_NAME=#{versionName} </select> <!-- APP版本號(hào)驗(yàn)證--> <select id="validateversionCode" resultType="java.lang.Integer"> select count(id) from dbc_app_version where VERSION_CODE=#{versionCode} </select>
感謝各位的閱讀!關(guān)于“BootStrap+Mybatis框架下如何實(shí)現(xiàn)表單提交數(shù)據(jù)重復(fù)驗(yàn)證”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
標(biāo)題名稱:BootStrap+Mybatis框架下如何實(shí)現(xiàn)表單提交數(shù)據(jù)重復(fù)驗(yàn)證
標(biāo)題網(wǎng)址:http://bm7419.com/article22/jjdjcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、搜索引擎優(yōu)化、建站公司、電子商務(wù)、外貿(mào)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)