且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使Spring访问下拉框的值

更新时间:2023-02-11 19:21:22

首先,您没有正确使用<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