spring - Accessing attribute with argument from file.properties in Java class -
let me explain want do:
i got properties containing property this:
message=hello {0}, welcome.
i'd access property in java class using string , set parameter in class.
i've use fmt:message , fmt:param display kind of property in jsp want manipulate in java object (i know how inject property class).
any idea on how this?
you can use java.util.resourcebundle , java.text.messageformat examples
private string getstring( string bundle, string key, string defaultvalue, object... arguments ){ string result = resourcebundle.getbundle( bundle ).getstring( key ); if ( result == null ){ result = defaultvalue; } if ( arguments.length > 0 && result != null ){ result = messageformat.format( result, arguments ); } return result; }
Comments
Post a Comment