如何访问 messages.properties 文件中定义的属性? [英] How to access to a property defined in messages.properties file?

查看:24
本文介绍了如何访问 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 文件中定义的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆