I am a new woman for Spring MVC when working on a project, there are cases of usage, where I am from the file Some data is needed to be retrieved and it is populated in jsp.
Public Hashmap & lt; String, ashline & lt; String & gt; & Gt; & Gt; GetFooterMoreLinks () {Hashmap & lt; String, hashmap & lt; String, Arlist & lt; String & gt; & Gt; & Gt; MyArray = New Hashmop & lt; String, Hashmop & lt; String, array list & lt; String & gt; & Gt; & Gt; (); Hashmap & lt; String, Arlist & lt; String & gt; & Gt; ValueArr = new hashmap & lt; String, Arlist & lt; String & gt; & Gt; (); ValueArr.put ("title", new arreelist & lt; string & gt; () {{add ("more link");}}); ValueArr.put ("row1", new arreelist & lt; string & gt; () {{add ("about-us"); add ("http://www.example.com");}}); ValueArr.put ("row2", new arreelist & lt; string & gt; () {{add ("investor relationship"); add ("http://www.example.com");}}); // myArray.put ("more_links", valueArr); Hashmap & lt; String, Arlist & lt; String & gt; & Gt; Partner Site Links = New Hashmop & lt; String, Arlist & lt; String & gt; & Gt; (); Partner Site LinksAreauput ("Heading", New Arreelist & lt; string & gt; () {{Ad ("Partner Heading");}}); PartnerSite LinksAreauput ("Line1", New Arreelist & lt; string & gt; () {{Add ("Support"); Add ("http://www.example.com");}}); PartnerSite LinksAreauput ("Line", "New Array" & lt; string & gt; () {{AD ("Daily Deal"); Add ("http://www.example.com");}}); // so on myArray.put ("partner_programs", partner SitesLinksArray); }
and in jsp myArray
census. EVERthing is working fine but I have to choose all these hard-coded values from the file. Please help! Because .properties does not support array like file format.
.configuration stored in the .properties file
Then you have your foo.properties The format and files may be more about using. Properties can be found in files. First of all, you need to declare bean that you use to reach your retired files. Or when you are using the Spring Java configuration, you must Then you can access the property file in your Javascript through property object. .properties File is required, which is a standout of Java properties with the following format:
some Property.key = 42 someother.property.key = The user name must be at least 5 characters long
Your qualities are visible to spring
& lt; Bean id = "my properties" category = "org.springframework.beans.factory.config.PropertiesFactoryBean" & gt; & Lt; Property Name = "Location" & gt; & Lt; List & gt; & Lt; Price & gt; Classpath *: foo.properties & lt; / Pricing & gt; & Lt; Price & gt; Classpath *: bar.properties & lt; / Pricing & gt; & Lt; / List & gt; & Lt; / Property & gt; & Lt; / Bean & gt;
@PropertySource ("Classpath: /com/myco/app.properties" ).
Use values in your spring beans
Alternatively, you can inject solid values directly from your property files. This is simple when you have a small amount of values @ Value annotation, you use the property name (key) to inject its value
@Value ("$ {some. Property.key} ") private string value;
No comments:
Post a Comment