如何使Spring访问下拉框的值 [英] How do make Spring access dropdown box values

查看:95
本文介绍了如何使Spring访问下拉框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置Spring访问下拉框的值.

How do make Spring access dropdown box values.

我正在尝试使Spring MVC获得我的下拉菜单之一的值.

I am trying to make Spring MVC get the value of one of my dropdowns.

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/view/dateRange.jsp at line 28

25: <tr>
26:     <td>
27:         <div align="right">Last Month Of Full Data:</div></td>
28:         <td><form:select path="Lst_mnt">
29:             <option value="1">January</option>
30:             <option value="2">February</option>
31: 

我为获取Spring的价值所做的一切都没有建立下拉列表

All that I am doing its to get the value into Spring not build the dropdown

推荐答案

首先,您没有正确使用<form:select>.您有两种选择:

First of all, you are not using the <form:select> properly. You have two options:

  • 使用一个简单的<select>标签,并在其中添加<option>标签,并为其指定一个与模型对象字段相对应的名称(在这种情况下,请使用Lst_mnt,但要避免使用下划线)
  • Map中使用<form:select>,您可以在其中填充选择键和值
  • use a simple <select> tag with <option> tags inside, and give it a name the corresponds to the model object field (Lst_mnt in this case, but avoid that underscore)
  • use <form:select> with a Map in which you can fill the keys and values for the select

因此,您将显示这些值.然后:

Thus you will show the values. Then:

  • 如果要获取选定的值-提交表单时,它将被填充到模型对象中,因此将其保存在控制器方法中.
  • 如果您想在浏览器中进行操作,请使用javascript

这篇关于如何使Spring访问下拉框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆