Does anybody have an idea on how to auto select option tag?
I checked at the spring form tag library but cant see any property related to an option value being selected by default when the JSP is rendered.
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="st开发者_开发技巧rPlant" />
</form:select>
</p>
and, I want an option from the list (ie. items="${plants}" , say 'NeemTree') to be shown as already selected when the page loades.
Thanks
The "selected Option" will be calculate by Spring MVC based on the path="" attribute.
In above case I think,
Either the value of path="strPlant" is null
OR
the array/collection/map represented by items="${plants}" attribute does not contain an element corresponding to path="strPlant" value.
e.g.
if path="strPlant" results in String NeemTree, items="" must have NeemTree as element.
itemLabel="strPlant" and itemValue="strPlant" make sense only if you are passing an instance of HashMap to items="" attribute.
Spring Reference Documentation
加载中,请稍侯......
精彩评论