检测商品简码是否唯一,不重复

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> {

 

}


 [d1]处理中午乱码

 [d2]Springside中,继承hibernatedao后直接调用

原文地址:https://www.cnblogs.com/pujiajia/p/3287255.html