日期:2014-05-18  浏览次数:20993 次

jsp问题,菜鸟求救!
最近在做毕业设计,一个B/S结构jsp程序.在我的一个页面a.jsp
<%@   page   contentType= "text/html;charset=gb2312 "   %>
<%@   include   file= "../importbao.jsp "%>
<%@   include   file= "mysession.jsp "%>
<%
int   id   =(null==request.getParameterValues( "id ")?1:(Integer.parseInt(request.getParameter( "id "))));
String   sql= "select   *   from   t ";
sqlBean   my   =   new   sqlBean();
my.setConnection();
my.setQuerystatement(sql);
ResultSet   Rst=my.getResult();
Rst.first();
Rst.previous();
%>
<script   Language= "JavaScript ">
<!--
function   check_input(frm)
{    
      ...
}
//-->
</script>
该页面有一个表单
<tabale>
<form   action= "b.jsp?id= <%=id%> "   name= "frm "   onsubmit= "return   check_input(this) "   method= "POST ">
表单里面有如下控件:

...
<select   name= "cmd ">     //自动从数据库获取选项
<%
      while(Rst.next())
          {        
                  out.print( " <option   value= ' ");
                  out.print(Rst.getString( "cname "));
                  out.print( " '> ");
out.print(Rst.getString( "cname "));
out.print( " </option> ");
        }  
               
%>
</select>  
...
<input   type= "checkbox "   name= "chkb1~chkb12 "   value= "1 "> 12个复选框,想实现选中为1,没选为0.
...
<input   type= "submit "   name= "Submit "   value= "授权 ">
<input   type= "reset "   name= "Submit2 "   value= "重置 ">
</tabale>

数据库中有一个t表,有一个cid(编号)   int   4,cname(名称)   varchar   20,还有crow1-crow12十二个tinyint型的字段,初始值我都给的0.

在b.jsp
<%@   page   contentType= "text/html;charset=gb2312 "   %>
<%@   include   file= "../importbao.jsp "%>
<%@   include   file= "mysession.jsp "%>
<%try{
String   cmd   =   new   String(request.getParameter( "cmd ").getBytes( "ISO8859_1 "), "GBK ");
int         chkb1   =   java.lang.Integer.parseInt(request.getParameter( "chkb1 "));
int         chkb2   =   java.lang.Integer.parseInt(request.getParameter( "chkb2 "));
...
int         chkb12   =   java.lang.Integer.parseInt(request.getParameter( "chkb12 "));
int   id   =   Integer.parseInt(request.getParameter( "id "));

String   sql= "update   t   set   crow1= "+chkb1+ "set "+  

"crow2= "+chkb2+ ",...crow12= "+chkb12+ "   where   cname= ' "+cmd+ " ' ";
sqlBean   myUpdate   =   new &