Spring MVC is the best way to populate a dropdown list - a properties file?

I want to populate a drop down list and I don't want to go to the database. I thought I had a list of countries or a list of languages ​​in the properties file. That way I could read this and then assign it to a variable. Then I could return this via the ModelAndView type.

Is this a good approach? I am not sure how to store static data. I do not want to keep it in the class, because it will be more difficult to update it if changes are necessary.

+5
source share
2 answers

! , , spring :

<util:map id="countryList" map-class="java.util.HashMap">
    <entry key="CA" value="Canada"/>
    <entry key="US" value="United States"/>
    <entry key="PK" value="Pakistan"/>
    <entry key="UE" value="UAE"/>
</util:map>

...

ModelAndView (, , , ModelAndView, spring)

${countryList} jsp do -
<form:select path="country">
<form:option value="NONE" label="--- Select ---"/>
<form:options items="${countryList}" />
</form:select>

. gyst of of, ! !!

+3

, ehCache. , , , .

0

All Articles