Default value to select option menu is not recognized
This question already has an answer here:
If you are using JSP
then there is a tag
for html-select-dropdown
. Using <form:select>
tag you can do something like this -
<form:select path="country">
<form:option value="NONE" label="--- Select ---"/>
<form:options items="${yourList}" />
</form:select>
To know more about how to use jsp select tag dig deep into this link.
And for assiging default value take help from this answer.
Update
This is how you can include JSTL
in you JSP
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
Here you see prefix="form"
, you can name the prefix
as you want. You can find more detail here.
The ="selected" part is not necessary. Just <option selected>
will do fine.
<select id="name" class="state">
<option selected value="Brad">
Brad
</option>
<option value="Carol">
Carol
</option>
<option value="Derrick">
Derrick
</option>
</select>
The value, in this case "Brad", would be passed as a string unless another option is selected.
链接地址: http://www.djcxy.com/p/88078.html下一篇: 无法识别选择选项菜单的默认值