Spring MVC <form:options> default value?

2019-08-04 05:12发布

问题:

Is there any way to select default value in dropdown list by Spring MVC by "< form:options>" ?

I mean: If an option's id is equal to my model attribute Id, I want to select them by default.

回答1:

If you do:

<form:select path="optionName">
    <form:options items="${your_option_types}" />
</form:select>

That will pre-select your model attribute value.



标签: spring-mvc