Struts ApplicationResource.properties in Detail
Industries standard principle in project development is don't hardcode(typing code) any values in the application that are changable in the future.
To make java,jdbc applications flexible collect driverclass name,url,database username,password details required for jdbc code from outside the application by using the support of properties file.
A file that contains entries in the form of key = value page is called properties file.
To make presentation logic labels of struts application flexible and reusable to pass from outside the jsp's take the support of properties file.
procedure to configure properties file with struts application to make presentation logic labels of jsp flexible.
Step 1).Prepare properties file having presentation logic value and save that file in WEB-INF\classes folder.
save as myfile.properties
properties file of struts application is visible in all the web-resources of struts application.
Step 2).Configure properties file with struts application in struts-config.xml file by using message-resources tag.(<message-resources>).
Step 3).Read the values from properties file as presentation logic labels of jsps by using "<bean:message>" tag.
One Struts applications can have multiple properties files.
To make java,jdbc applications flexible collect driverclass name,url,database username,password details required for jdbc code from outside the application by using the support of properties file.
A file that contains entries in the form of key = value page is called properties file.
abc.properties |
Properties file can also be called as ResourceBundle file or ApplicationResource file.Then properties file is used in struts application.The file must contain ".properties" as extension.when it is used in other applicationany extension can be there.
To make presentation logic labels of struts application flexible and reusable to pass from outside the jsp's take the support of properties file.
procedure to configure properties file with struts application to make presentation logic labels of jsp flexible.
Step 1).Prepare properties file having presentation logic value and save that file in WEB-INF\classes folder.
# -- myfile.properties -- btn.add=Add btn.sub=Sub btn.mul=Mul btn.div=Div
save as myfile.properties
properties file of struts application is visible in all the web-resources of struts application.
Step 2).Configure properties file with struts application in struts-config.xml file by using message-resources tag.(<message-resources>).
<message-resources parameter="com.javabynataraj.lookupdispatch.ApplicationResource"/>
Step 3).Read the values from properties file as presentation logic labels of jsps by using "<bean:message>" tag.
<bean:message key = "btn.add"/> <bean:message key = "btn.sub"/> <bean:message key = "btn.mul"/> <bean:message key = "btn.div"/>
One Struts applications can have multiple properties files.