首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

用Servlet做表单提交连接数据库等综合有关问题

2012-01-02 
用Servlet做表单提交连接数据库等综合问题我要给一个web页面上的内容作数据库连接这是一个要提交的表单里

用Servlet做表单提交连接数据库等综合问题
我要给一个web页面上的内容作数据库连接   这是一个要提交的表单   里面有很多复选框   我用html做的   然后我要另外写一个Java类用于收集这些数据   request.getparameter( "复选框名字 ")   这是一个什么类型的数据   我怎样判断它是否选中   isselected()点不出来的   具体怎么做   还有进入数据库我想把boolean值转换成bit类型的   请高手赐教!!!   有没有这方面的例子?

[解决办法]
request.getParameter就行了啊。要是你的复选框有被选中的话,就会得到值。
多个被选中的话得到的就是个数组。

test.jsp

<html>
<head> <title> lskj </title> </head>
<body>
<form method=post action= "test1.jsp " >
<input type= "checkbox " name= "aa " value= "bb ">
<input type= "checkbox " name= "aa " value= "aa ">
<input type= "checkbox " name= "aa " value= "cc ">
<input type= "checkbox " name= "aa " value= "dd ">
<input type= "checkbox " name= "aa " value= "ee ">
<input type= "checkbox " name= "aa " value= "ff ">
<input type= "checkbox " name= "aa " value= "gg ">
<input type=submit value= "submit ">
</form>
</html>

test1.jsp

<html>
<head> <title> sflj </title> </head>
<body>
<%
String []results = request.getParameterValues( "aa ");
if(results != null){
for(int i = 0 ; i < results.length; i ++)
out.print(results[i]);
}

%>

</body>
</html>

热点排行