我如何覆盖Grails中的默认错误消息? [英] How can I override the default error message in Grails?
本文介绍了我如何覆盖Grails中的默认错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有姓氏字段的Person对象。 lastName字段不能为空。当用户在lastName字段中提交表单空白值时,用户看到的错误消息是:
I have a Person object with a lastName field. The lastName field cannot be blank. When the user submits a form blank value in the lastName field, the error message that the user sees is:
Property [lastName] of class [com.example.Person] cannot be blank
这个错误信息是蹩脚的。我想将它定制为更加用户友好的内容,比如姓氏字段不能为空
This error message is lame. I want to customize it to something more user friendly, like "The Last Name field cannot be blank"
我该怎么做?
推荐答案
请参阅文档的第7章: http: //grails.org/doc/latest/
See Chapter 7 of the docs: http://grails.org/doc/latest/
您可以更改 grails-app / i18n / messages.properties
并添加
You would change grails-app/i18n/messages.properties
and add
person.lastName.blank=The Last Name field cannot be blank
这篇关于我如何覆盖Grails中的默认错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文