开发者

Playframework: Best Solution for loading & using constant Strings

开发者 https://www.devze.com 2023-03-19 14:20 出处:网络
I have a bunch of static Strings that I\'d like to store in a .yml file. What\'s the best design practice to load them to a Java Class & use it.

I have a bunch of static Strings that I'd like to store in a .yml file. What's the best design practice to load them to a Java Class & use it.

In other words, I'm looking for an Application-wide Singleton class holding resource strings, but confused as to where to put them (Models, Controllers).

I also don't want to make any obvious mistakes that'll hit performance

Update: found the solution ht开发者_JS百科tp://www.playframework.org/documentation/1.2.2/i18n#messages


Although you found the solution, just a little note - by convention, most of your code lives in the "controllers", "models", and "views" packages (and the "notifiers" package if you use stuff like templated mail), but nothing bars you of adding more of your own. I often end up with at least a "utils" package :)


Update: found the solution http://www.playframework.org/documentation/1.2.2/i18n#messages

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号