$(function(){
$("#frm").validateForm({
rules:{
'caResourceStandard.resourceName':{
required:true,
remote:{
type:"post",
url:"/concealedacceptance/caResourceStandard!duplicateCheck.action",
data:{
"caPreDataStandard.id":function(){return $("#id").val();},
},
},
},
},
messages:{
'caResourceStandard.resourceName':{
required:"此处不能为空",
remote:"该资料名称已存在!"
}
}
});
})
public void duplicateCheck(){ Integer count = null; Map<String,String> map = new HashMap<String, String>(); map.put("id", caResourceStandard.getId()); map.put("resourceName", caResourceStandard.getResourceName()); count = caResourceStandardService.countResourceName(map); try { response.getWriter().print(count>0?false:true); } catch (IOException e) { e.printStackTrace(); } }
<select id="countResourceName" parameterType="java.util.Map" resultType="Integer"> SELECT COUNT(1) FROM CA_RESOURCE_STANDARD WHERE RESOURCE_NAME = #{resourceName} AND Z_STATUS = 1<if test="id != null and id != ''">AND ID !=#{id}</if> </select>