问题
I need to have access to my properties file from GSP file to get one of it's values. I tried to find example over the web, but I couldn't. This is a file which I created and not Grails.
Thanks!
回答1:
If the properties file is under grails-app/i18n/ (it can be your own properties file, doesn't have to be one of the default ones) then you can access property values from the property file in a GSP using the message tag. See http://grails.org/doc/latest/ref/Tags/message.html.
回答2:
you can access aaplicationContext from the GSP ... so you can access any configuration property.
Just look at this entry from Mr. Haki: http://mrhaki.blogspot.com.es/2011/11/grails-goodness-get-grailsapplication.html
回答3:
If you are reading simple properties it sounds like what you want is externalized configuration
To use it in a GSP (if you really need to, but not recommended from a GSP):
${Holders.config.myPropertyKey}
来源:https://stackoverflow.com/questions/23364829/grails-how-to-access-properties-file-from-gsp