我寫一個Grails(目前2.3.3)應用程序並創建了一個validateable命令自定義錯誤消息的對象類似以下內容:Grails的定義命令對象
@Validateable
class MyCustomCommand {
String name
static constraints = {
name blank: false
}
}
在我i18n/messages.properties
文件I定義了以下屬性來覆蓋默認的錯誤消息。
MyCustomCommand.name.blank=Name must be provided.
MyCustomCommand.name.null=Name must be provided.
根據我的說法,每個Grails文檔應採用格式[Class Name].[Property Name].[Constraint Code]
。當我運行我的應用程序時,如果我將值留空,我仍然得到null屬性的默認消息。
我也嘗試了下面的默認消息的例子,並定義它們如下,但仍然得到默認消息。
MyCustomCommand.name.blank.message=Name must be provided.
MyCustomCommand.name.null.message=Name must be provided.
我假設我在這裏錯過了一些簡單的東西,但尚未偶然發現什麼。任何建議,我在做什麼不正確?
我相信這是第一個變化我試過了,我剛纔試了一下,還是把默認。 – Michael
哎呀我錯過了零件,而關於所有關於小寫的情況。糾正。 :) – dmahapatro