2010-12-19 40 views
0

請幫我解決這個問題。這次我會更具體一些,因爲我已經得到了一個解決方案,並且讓這個工作成爲可能。我有一個班級:grails/gorm消息包

package aa1 

class City { 

    String name 

    static constraints = { 
     name(blank: false, nullable:false, unique: true, matches:"[a-zA-z ]+") 
    } 

    String toString(){ 
     name 
    } 
} 

我想爲此做一個自定義的錯誤消息。爲此,我在messages.proprietis增加(因爲我不知道什麼是約束語法的類型):

aa1.City.name.doesnt.match=Letters between a-z and spaces. 
aa1.City.name.match=Letters between a-z and spaces. 
aa1.City.name.matches=Letters between a-z and spaces. 

我得到的錯誤信息是:

Property [username] of class [class trafficmanfinal.User] with value ["] does not match the required pattern [[a-zA-z0-9]+] 

我可以」噸得到這個工作。並讓我知道是否有任何自定義錯誤語法的列表來幫助我在網絡中。

回答

0

嘗試

aa1.City.name.matches.invalid=the message 
+0

沒有工作,我不知道爲什麼..它應該工作。其他消息的工作,這一個不。 – John 2010-12-19 01:54:03

+0

@john我更新了我的答案。在你的其他問題中,我的答案是不正確的。你應該取消勾號。 – hvgotcodes 2010-12-19 02:03:54

+0

@john,我修正了另一個答案;)但是你應該刪掉這個問題或其他的問題。上面的工作是我做的嗎?它現在應該。 – hvgotcodes 2010-12-19 02:11:11