Does Java and/or Spring have the concept of properties? I have bunch of domain models, each of which has several properties. Example:
public class Person {
private String name;
private Date dateOfBirth;
private float height;
private float weight;
// getters and setters not shown
}
When displaying a person, the property names are hardcoded in the JSP.
Name: ${person.name}<br>
Date of birth: ${person.dateOfBirth}<br>
Height: ${person.height}<br>
Weight: ${person.weight}<br>
Furthermore, there may be several different pages that display a person. Note that date of birth is a java.util.Date
, so the JSP or controller will use java.text.SimpleDateFormat
to format it. Height and weight are numbers, and they may have their own java.util.Format
used for formatting.
What I'm looking for a property lookup mechanism. Each property (name, date of birth, height, etc) would have the display name, format, and description (used for help or tooltips). The properties' attributes would be defined in a configuration file somewhere. When displaying a property, the display name and format would be looked-up via the property mechanism. This would also solve localization.
My question is if there's already something like this implemented for Java.