`
dellsoft
  • 浏览: 110658 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

grails 开发总结

阅读更多

在使用grails 开发的过程,一些总结,随笔

 

 

1)grails 连接sybase数据乱码解决办法

 

url = "jdbc:sybase:Tds:URL:5000/jxcbase?CHARSET_CONVERTER_CLASS=com.sybase.jdbc2.utils.Cp850PureConverter"

 

2)自定义Sql查询

Domain.executeQuery("select user from Buser user where user.name =?",["a"],[max:20,offset:20])

 

3)统计数据量

Domain.count()

Domain.countByFbh()

 

3) 保存时候,自定义错误显示

 

     newHzdwzd.errors.allErrors.each {

          errTexts += getFormatString("${it.objectName}", it.defaultMessage, it.rejectedValue, it.arguments) + "\r\n"

        }

 

  public String getFormatString(String domain,String p,String rejectedValue,Object[] b){

    String[] np = new String[b.length];

    String t = "";

    for (int i =0;i<b.length;i++) {

      Object o =  b[i] ;

      if (o instanceof String) {

        t = o.toString();

        if (t.equals(rejectedValue)) {

          np[i] = rejectedValue;

        }else{

          np[i] = getLabel(domain.toLowerCase()+"."+t);

        }

      }else if (o instanceof Class) {

        t =  ((Class) o).getName();

        np[i] = getLabel(t.toLowerCase());

      }else{

        np[i] = o.toString()

      }

 

    }

    return MessageFormats.format(p,np);

  }

 

   public String getLabel(String name) {

    return Labels.getLabel(name.toLowerCase(),name.toLowerCase()) ;

  }

 

  在i3lable-propereies 文件中配置 domain 的相关信息

 

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics