我现在在某些条件下通过message.properties在我的应用程序中显示文本,我必须显示类似的消息,但要稍作更改。是否可以仅在消息属性中检查条件,例如:
if (a == salary) {
code = your salary for this month is {0}
}else if (a == tax) {
code = your tax for this month is {0}
}
现在在这种情况下,文本中唯一的区别是薪金和税金,而不是在 Controller 中检查它,或者我只想在message.properties中检查此条件。可能吗 ?如果是,怎么办?
谢谢 !提前。
最佳答案
我认为您不需要检入messages.properties,只需将代码更改为
your {0} for this month is {1}
并在消息中传递
a
作为参数,例如g.message(code: 'adminUsers.restore.confirm.message', args: [a, 'XXX'])
关于grails - 是否可以在message.properties文件中写入表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19243749/