日期:2014-05-20  浏览次数:20740 次

复选框里的数据怎样传入oracle数据库中?童鞋们,有劳了!!!
<tr>
  <td>爱好:</td>
  <td><label>
  <input type="checkbox" name="hobby" id="checkbox" value="上网"/>
  上网
  <input type="checkbox" name="hobby" id="checkbox2" value="听音乐"/>
  听音乐
  <input type="checkbox" name="hobby" id="checkbox3" value="看书"/>
  看书
  <input type="checkbox" name="hobby" id="checkbox4" value="运动"/>
  运动
  <input type="checkbox" name="hobby" id="checkbox5" value="旅游"/>
  旅游
  <input type="checkbox" name="hobby" id="checkbox6" value="聊天"/>
  聊天
  <input type="checkbox" name="hobby" id="checkbox7" value="看片"/>
  看片</label></td>
我写了两个servlet,一个aadMessageServlet,用来添加数据到数据中
String sql="insert into information(id,name,englishName,homepage,password,config,email,qq,idCard,age,phone,cellphone,birth,postal,os,province,hobby,brief,ougr)" +"values(seq_order.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
添加语句是:
request.setCharacterEncoding("UTF-8");
  String name= request.getParameter("name");
  String homepage= request.getParameter("homepage");
  String password1= request.getParameter("password1");
  String config= request.getParameter("config");
  String email= request.getParameter("email");
  String qq= request.getParameter("qq");
  String idCard= request.getParameter("idCard");
  String age= request.getParameter("age");
  String phone= request.getParameter("phone");
  String birth= request.getParameter("birth");
  String postal= request.getParameter("postal");
  String os=request.getParameter("os");
  String province = request.getParameter("province");
  String hobby = request.getParameter("hobby");

   
  Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection(url,username,password);
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1, StringUtil.filterHtml(name));
pstmt.setString(2, request.getParameter("englishName"));
pstmt.setString(3, StringUtil.filterHtml(homepage));
pstmt.setString(4, StringUtil.filterHtml(password1));
pstmt.setString(5, StringUtil.filterHtml(config));
pstmt.setString(6, StringUtil.filterHtml(email));
pstmt.setString(7, StringUtil.filterHtml(qq));
pstmt.setString(8, StringUtil.filterHtml(idCard));
pstmt.setString(9, StringUtil.filterHtml(age));
pstmt.setString(10, StringUtil.filterHtml(phone));
pstmt.setString(11, request.getParameter("cellphone"));
pstmt.setString(12, StringUtil.filterHtml(birth));
pstmt.setString(13, StringUtil.filterHtml(postal));
pstmt.setString(14, StringUtil.filterHtml(os));
pstmt.setString(15, StringUtil.filterHtml(province));
pstmt.setString(16, StringUtil.filterHtml(hobby));
pstmt.setString(17, request.getParameter("brief"));
pstmt.setString(18, request.getParameter("ougr"));

  但是对于复选项只能添加一项进去啊 ???求教,谢谢!!!

------解决方案--------------------