java中获取下拉框的值是可以使用request.getParameter(下拉框定义的名称)方法来获取。
具体代码如下:
Servlet类:
public class DemoServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println(request.getParameter("name"));
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
代码如下:
1,用getSelectedItem()得到序号
2 用当前序号得到下拉变量的text值