本文介绍了如何访问 messages.properties 文件中定义的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Groovy Grails 应用程序,我想以编程方式访问 messages.properties 中定义的属性.
I have a Groovy Grails application and I want to access programmatically to a property defined in messages.properties.
作为测试,我尝试了以下语句:
As a test, I've tried the following statement:
println "capacity.created: ${messages.properties['capacity.created']}"但它不起作用(抛出异常).
But it doesn't work (throws an exception).
欢迎任何帮助.
路易斯
推荐答案我找到了一种无需重新阅读所有内容即可直接访问消息属性的方法消息属性文件(message_de.properties、message_fr.properties 等)这很容易.
I found a way to access to message properties directly wothout re-reading all the messages properties files (message_de.properties, message_fr.properties, etc.) It is is very easy.
message(code:"capacity.created")它有效!
路易斯
更多推荐
如何访问 messages.properties 文件中定义的属性?
发布评论