<s:textfield id=”code” name=”yhaoPortalsDownBean.downFlag” cssClass=”textfrom” cssStyle=”width:150px;” maxlength=”200″/>
<font id=”codeInfo” color=”red”>*</font>
</div></td>
</tr>
步骤四 action里的方法
/**
*
* @author ZhuangZi
* @class com.hzdracom.action.YhaoPortalsDictionaryAction
* @method checkCodeOnly
* @Directions 验证唯一标识公用方法
* @date 2013-3-21上午10:09:04 void
*/
public void checkCodeOnly(){
String json=””;
try{
json = String.valueOf(yhaoDictionaryService.checkCodeOnly(bean));
json=JSON.toJSONString(json);
System.out.println(“json==”+json);
HttpServletResponse response=ServletActionContext.getResponse();
response.setContentType(“text/html”);
response.setCharacterEncoding(“utf-8”);
PrintWriter out;
out = response.getWriter();
out.println(json);
out.flush();
out.close();
}catch(Exception e){
e.printStackTrace();
}
}
步骤五 dao里的方法
<PRE class=java name=”code”> public int checkCodeOnly(DictionaryBean bean)throws DataAccessException,Exception {
Object[] sqlParams = new Object[4];
int index = 0;
String sql=””;
/* 验证页面标志是否唯一*/
if (bean.getFlag().equals(“1”)) {
sql = “select count(1) from YHAO_PORTALS_PAGE where PAGE_FLAG = ? “;
sqlParams[index]=bean.getCode();
index++;
}
/* 验证类型志标识是否唯一*/
if (bean.getFlag().equals(“2”)) {
sql = “select count(1) from YHAO_PORTALS_DOWNTYPE where DOWNTYPE_FLAG = ? “;
sqlParams[index]=bean.getCode();
index++;
}
/* 验证下载志标识是否唯一*/
if (bean.getFlag().equals(“3”)) {
sql = “select count(1) from YHAO_PORTALS_DOWN where DOWN_FLAG = ? “;
sqlParams[index]=bean.getCode();
index++;
}
if (bean.getFlag().equals(“4”)) {
sql = “select count(1) from YHAO_PORTALS_KUAI where KUAI_FLAG = ? “;
sqlParams[index]=bean.getCode();
index++;
}
Object[] sqlParamsEnd = new Object[index];
System.arraycopy(sqlParams, 0, sqlParamsEnd, 0, index);
int count = this.queryForInt(sql,sqlParamsEnd);
return count;
}</PRE>
<PRE></PRE>










