本文介绍了如何访问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文件中定义的属性?
发布评论