I am developing a simple GUI in which i want username value to be fetched from ApplicationResources.properties file. My file contains following two lines :
label.username= Username
label.password=Password
I am using JSP containing struts 2 tag contains following snippet :
<s:textfield cssClass="login-inp" name="username" key="label.username" size="20" />
But when i run my project i see label.username that indicates value from properties file is not read.. am i missing something ? How to solve this problem ? Kindly help
thanks in advance
I am not sure where and how you have defined the
properties
file but when searching for resource bundles struts2 search them in a specific wayrefer document for details /internationalization.
Additionally The Struts 2 key attribute can be used in the textfield tag to instruct the framework what value to use for the textfield's name and label attributes.Instead of providing those attributes and their values directly, you can just use the key attribute.
So either use name="username" key="label.username".
Just go through the official documents for details how this work and how framework search for the property files message-resource-files