Heim >Web-Frontend >js-Tutorial >jquery struts 验证唯一标识(公用方法)_jquery
public int checkCodeOnly(DictionaryBean bean)throws DataAccessException,Exception { <br>Object[] sqlParams = new Object[4]; <br>int index = 0; <br>String sql=""; <br>/* 验证页面标志是否唯一*/ <br>if (bean.getFlag().equals("1")) { <br>sql = "select count(1) from YHAO_PORTALS_PAGE where PAGE_FLAG = ? "; <br>sqlParams[index]=bean.getCode(); <br>index++; <br>} <br>/* 验证类型志标识是否唯一*/ <br>if (bean.getFlag().equals("2")) { <br>sql = "select count(1) from YHAO_PORTALS_DOWNTYPE where DOWNTYPE_FLAG = ? "; <br>sqlParams[index]=bean.getCode(); <br>index++; <br>} <br>/* 验证下载志标识是否唯一*/ <br>if (bean.getFlag().equals("3")) { <br>sql = "select count(1) from YHAO_PORTALS_DOWN where DOWN_FLAG = ? "; <br>sqlParams[index]=bean.getCode(); <br>index++; <br>} <br>if (bean.getFlag().equals("4")) { <br>sql = "select count(1) from YHAO_PORTALS_KUAI where KUAI_FLAG = ? "; <br>sqlParams[index]=bean.getCode(); <br>index++; <br>} <br>Object[] sqlParamsEnd = new Object[index]; <br>System.arraycopy(sqlParams, 0, sqlParamsEnd, 0, index); <br>int count = this.queryForInt(sql,sqlParamsEnd); <br>return count; <br>}