如何获取所选项的值和标签

时间:2013-02-20 06:12:29

标签: spring jsp spring-mvc label

  

我在jsp上的代码:

<form:select id="accountId" path="accountId" >  
<c:forEach items="${accountTypeList}" var="var">
<form:option value="${var.accountId}" label="${var.accountNo}"></form:option>
</c:forEach>
</form:select>
  

我想要控制器中所选条目的值和标签。

1 个答案:

答案 0 :(得分:0)

请检查Get text of select option's label and populate it in a hidden input field

您可以使用隐藏字段并使用javascript / jquery填充该字段,因此当您提交该表单时,您可以获得该值。

- 更新

如果您仍在下一页中使用accountNo,则可以在表单类中添加一些临时变量,例如accountNo2。