在java中如何把下拉列表框中的值获取?jsp页面跳转到servlet里面,在servlet里获值!

2024-11-29 09:58:25
推荐回答(3个)
回答1:



用户名:

密码:

性别:



所在地:



爱好:
唱歌
跳舞
篮球

备注:


大头照:





public class RequestDemo2 extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String value = request.getParameter("username");
if(value!=null&&!value.trim().equals("")){
System.out.println(value);
}

System.out.println("------------------------------");

Enumeration e = request.getParameterNames();
while(e.hasMoreElements()){
String name = e.nextElement();
value = request.getParameter(name);
System.out.println(name + "="+value);
}
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

}
}

回答2:



用户名:

密码:

性别:



所在地:



爱好:
唱歌
跳舞
篮球

备注:


大头照:





public class RequestDemo2 extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String value = request.getParameter("username");
if(value!=null&&!value.trim().equals("")){
System.out.println(value);
}

System.out.println("------------------------------");

Enumeration e = request.getParameterNames();
while(e.hasMoreElements()){
String name = e.nextElement();
value = request.getParameter(name);
System.out.println(name + "="+value);
}
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

}
}

回答3:

如果jsp页面是form提交的话,直接在后台 request.GerParameter()获取便可以啊!获取