首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

grails 开发小结

2012-11-01 
grails 开发总结在使用grails 开发的过程,一些总结,随笔??1)grails 连接sybase数据乱码解决办法?url jd

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 的相关信息

?

?

热点排行