如何访问在messages.properties 文件中定义的属性?

编程入门 行业动态 更新时间:2024-10-09 03:21:19
本文介绍了如何访问在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 文件中定义的属性?

本文发布于:2023-11-28 17:51:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   定义   文件   messages   properties

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!