jsp
<div class="form">
<label class="Validform_label">选项编号: </label>
<input name="typecode" class="inputxt" value="${type.typecode }" datatype="/^[A-Za-z0-9\u4E00-\u9FA5\uf900-\ufa2d\.\s]{1,50}$/"
ajaxurl="dbTypeGroupController.do?checkType&code=${type.typecode }&typeGroupCode=${typegroup.typegroupcode}">
<span class="Validform_checktip"><t:mutiLang langKey="common.range1to10" /></span>
</div>
controller
/**
* 检查字段是否重复
*
* @param request
* @return
*/
@RequestMapping(params = "checkType")
@ResponseBody
public ValidForm checkType(HttpServletRequest request) {
ValidForm v = new ValidForm();
String typecode=oConvertUtils.getString(request.getParameter("param"));
String code=oConvertUtils.getString(request.getParameter("code"));
String typeGroupCode=oConvertUtils.getString(request.getParameter("typeGroupCode"));
StringBuilder hql = new StringBuilder("FROM ").append(DbCheckTypeEntity.class.getName()).append(" AS entity WHERE 1=1 ");
hql.append(" AND entity.typeGroup.typegroupcode = ?");
hql.append(" AND entity.typecode = ?");
List<Object> types = this.systemService.findHql(hql.toString(),typeGroupCode,typecode);
if(types.size()>0&&(code==null||!code.equals(typecode)))
{
v.setInfo("类型已存在");
v.setStatus("n");
}
return v;
}
效果