Action:
/*
* 检测商品简码是否唯一,不重复
*/
public String checkCode() throws Exception {
try {
HttpServletRequest request = Struts2Utils.getRequest();
String goodscode = request.getParameter("goodscode");
String oldGc = request.getParameter("oldGc");
goodscode = new String(goodscode.getBytes("iso8859-1"), "UTF-8");
oldGc = new String(oldGc.getBytes("iso8859-1"), "gb2312");
[d1] if (busiGoodManager.isCodeUnique(goodscode, oldGc)) {
Struts2Utils.renderText("true");
} else {
Struts2Utils.renderText("false");
}
} catch (Exception ex) {
logger.error(ex.getMessage());
Struts2Utils.renderText("false");
}
return NONE;
}
Service:
public boolean isCodeUnique(String name, String oldName) {
return busiGoodDao.isPropertyUnique[d2] ("goodscode", name, oldName);
}
Dao:
/**
*商品的泛型DAO类.
*
* @author ligy
*/
@Component
public class BusiGoodDao extends HibernateDao<BusiGood, Long> {
}