Default Auto Option Tag in Spring MVC

Does anyone have an idea how to automatically select an option tag?

I checked the spring form tag library, but I don't see any property associated with the parameter value that is selected by default when rendering the JSP.

I basically have this:

<p>
    <label for="plantLabel" class="label">Plant:</label> 
    <form:select path="strPlant" >
        <form:option value="-" label="--Select Please--" />
        <form:options items="${plants}" itemLabel="strPlant"
            itemValue="strPlant" />
    </form:select>
</p>

and I want a parameter from the list (for example, items = "$ {plants}", for example 'NeemTree') to appear as already selected when the page loads.

thank

+3
source share
1 answer

The "selected option" will be calculated using Spring MVC based on the attribute path="".

In the case above, I think

path="strPlant" null

//map, items="${plants}", , path="strPlant".

. path="strPlant" String NeemTree, items="" NeemTree .

itemLabel="strPlant" itemValue="strPlant" , HashMap items="".

Spring

+5

Source: https://habr.com/ru/post/1753662/


All Articles