你把他放到form中
注意要触发你的servlet
注意要触发你的servlet
解决方案 »
- css引入jsp问题
- WEB上自动获得分辨率大小
- jdbcTemplate 执行带返回参数存储过程的问题
- 为什么跳转的总是错误页面?
- 如何放置媒体文件所在的的层?
- 求助:ServletResponse输出流导致Java虚拟机OutOfMemoryError
- 很菜的问题,求教
- 请问我下载什么编译器啊?????
- hashtable处理数据库的操作错在哪里?
- struts中怎样给"<html:submit property="submit" value="submit"/>"之类的加.css叫...
- Struts小问题,不知道大家留意过没有!
- SmartUpload 类在编译的时候被删除了,怎么解决?
String value1=request.getParameterValues("check1");
String value2=request.getParameterValues("radio1");
“<input type="checkbox" name="check1" value="0">
input type="radio" name="radio1" value="0">”版主的这段代码少了一个“<”不是知道是写错了,还是程序里就是这样的!
我同意第一位兄弟的看法,你的input是不是放到了form里!
忘说了!上面仁兄的getParaemterValues()的方式,对应的应该是一个数组!
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String sql=null;
String[] o_id=request.getParameterValues("o_id");
for(int i=0;i<o_id.length;i++){
System.out.println(o_id[i]);
try{
sql="update survey_option set o_check_count=o_check_count+1 where o_id="+o_id[i];
System.out.println(sql);
ps.execute(sql);
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
response.sendRedirect("web/index.jsp?msgcode=1");
}
<html>
<title></title>
<body>
<form action=test1.jsp name=test1>
<input name=checkbox type=checkbox value="a">aaaaaaa
<input name=radio type=radio value="b">bbbbbb
<select name=select >
<option value="0">000000</option>
<option value="1">111111</option>
<option value="2">222222</option>
</select>
<input name=sub type=submit>
</form>
</body>
</html>test1.jsp代码如下:
<html>
<title></title>
<body>
<%
String a=request.getParameter("radio");
String b=request.getParameter("checkbox");
String c=request.getParameter("select");
out.println(a);
out.println(b);
out.println(c);
%>
</body>
</html>
运行成功!
哦!对了!改正一下!刚刚我说的checkbox是不用getParameterValues的
check是多选的,但是每次只能传一个值!这个方法是传送多个值用的!
这一方法多用在select上!
String b=request.getParameter("复选框名称");这条语句得到什么?能得到value值吗?好像它是判断复选框是不是被选中吧?
request.getParameterValues("复选框名称");
我就是这样写的呀?
请问这是什么原因?大家做的时候是不是也是这样呀?
request.getParameterValues("复选框名称");