Home > Web Front-end > JS Tutorial > Detailed introduction to code sharing for repeated verification of form submission data under the BootStrap+Mybatis framework

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

黄舟
Release: 2017-03-24 14:37:03
Original
2065 people have browsed it

This article mainly introduces the repeated verification function of form submission data under the BootStrap+Mybatis framework. It is very good and has reference value. Friends in need can refer to it

Effect:

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

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

##jsp page:

<form class="form-horizontal lui-tj-bd" id="dbc_code_add_form" method="post">
<p class="row">
<p class="col-xs-12">
<!-- PAGE CONTENT BEGINS -->
<p class="tabbable">
<p class="space-12"></p>
<p class="profile-user-info profile-user-info-striped">
<p class="profile-info-row">
<p class="profile-info-name" > 版本号<font color="red">*</font></p>
<p 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" />
</p>
</p>
<p class="profile-info-row">
<p class="profile-info-name" > 版本名称<font color="red">*</font></p>
<p 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"/>
</p>
</p>
<p class="profile-info-row">
<p class="profile-info-name" > 上传应用程序<font color="red">*</font></p>
<p class="profile-info-value">
<input type="file" name="file_upload" id="file_upload" />
</p>
</p>
<p class="profile-info-row ">
<p class="profile-info-name"> 下载地址<font color="red">*</font> </p>
<p 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>
</p>
</p>
<p class="profile-info-row">
<p class="profile-info-name" > 更新备注<font color="red">*</font></p>
<p class="profile-info-value">
<textarea class="col-sm-9 col-xs-12 " rows="5" id="updateLog" name="updateLog" >${list.updateLog}</textarea>
</p>
</p>
</p>
<p class="space-24"></p>
<p>
<p class=" col-md-offset-2 col-md-9 col-xs-12">
<p class=" col-xs-6">
<button class="btn btn-sm btn-success" type="button" id="saveButton2" style="float:right;" onclick="tobaocun()">
<i class="ace-icon fa fa-check "></i>保存
</button>
</p>
<button class="btn btn-sm btn-purple" type="reset">
<i class="ace-icon fa fa-undo "></i> 重置
</button>
</p>
</p>
</p>
</p>
</p>
</form>
Copy after login

js:

ace.load_ajax_scripts(scripts, function () {
 jQuery(function ($) {
 //验证
  $("#dbc_code_add_form").validate({
 rules: {
 &#39;versionCode&#39;: {
 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"
   }
 },
 &#39;versionName&#39;: {
 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"
   }
 },
 &#39;updateLog&#39;: {
 required: true,
 maxlength:125
 }
 },
 messages:{
 &#39;versionCode&#39;:{
 required: "<font color=&#39;#d16e6c&#39;>必填</font>",
 remote:"<font color=&#39;#d16e6c&#39;>版本号重复</font>",
 maxlength:"<font color=&#39;#d16e6c&#39;>最大不能超过10位</font>"
 },
 &#39;versionName&#39;:{
 required: "<font color=&#39;#d16e6c&#39;>必填</font>",
 remote:"<font color=&#39;#d16e6c&#39;>版本名称重复</font>",
 maxlength:"<font color=&#39;#d16e6c&#39;>最大不能超过40位</font>"
 },
 &#39;updateLog&#39;:{
 required: "<font color=&#39;#d16e6c&#39;>必填</font>",
 maxlength:"<font color=&#39;#d16e6c&#39;>最大不能超过120位</font>"
 }
 }
 });
 });
});
Copy after login

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;
 }
Copy after login
@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;
 }
Copy after login

service service layer

@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;
}
Copy after login

dao layer

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

mapper.xml

<!-- APP版本名称验证-->
 <select id="validateversionName" resultType="java.lang.Integer">
select 
count(id)
from dbc_app_version
where VERSION_NAME=#{versionName}
</select>
<!-- APP版本号验证-->
 <select id="validateversionCode" resultType="java.lang.Integer">
select 
count(id)
from dbc_app_version
where VERSION_CODE=#{versionCode}
</select>
Copy after login

The above is the detailed content of Detailed introduction to code sharing for repeated verification of form submission data under the BootStrap+Mybatis framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template