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

请各位大侠帮忙改下!
我的JSP代码是这样的:
<%@   page   language= "java "   contentType= "text/html;   charset=GB2312 "
pageEncoding= "GB2312 "%>
<%@   page   import= "java.util.* "%>
<%@   page   import= "java.sql.* "%>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=GB2312 ">
<title> FX订饭 </title>
</head>
<body>
<h2> 订饭喽 </h2>
<form   name= "form1 "   method= "post "   action= "Ex5_2.jsp?action=submit ">
<table   width= "59% "   height= "156 "   border= "0 "   cellpadding= "0 "
cellspacing= "0 ">
<tr>
<td   width= "21% "> 姓名: </td>
          <td   width= "79% ">     <input   name= "name "   type= "text "   size= "10 "> </td>
              <br>
<P> 今日菜谱:
              <br>
                  <input   type= "radio "   name= "meal "   value= "茄子 "> 茄子
              <input   type= "radio "   name= "meal "   value= "鸡丁 "> 鸡丁
              <input   type= "radio "   name= "meal "   value= "肉燥 "> 肉燥
              <input   type= "radio "   name= "meal "   value= "排骨 "> 排骨
      <br>
<tr>
<td> &nbsp; </td>
<td> <input   type= "submit "   name= "Submit "   value= "添加 "> </td>
</tr>
</table>
</form>

<font   size=2>  
<% //连接需要的对象
Connection   conn   =   null;
Statement   stmt   =   null;
String   sql   =   null;
ResultSet   rs   =   null;
int   ret;
String   action   =   request.getParameter( "action ");
if   ( "submit ".equals(action))   {
String   name   =   request.getParameter( "name ");
String   meal   =   request.getParameter( "meal ");
Timestamp   addtime   =   new   Timestamp(System.currentTimeMillis());

try   {
Class.forName( "com.mysql.jdbc.Driver ");   //载入JDBC驱动程序
String   strCon   =   "jdbc:mysql://localhost:3306/JspSamples ";   //连接字
conn   =   DriverManager.getConnection(strCon,   "root ",   "123456 ");   //连接数据库
stmt   =   conn.createStatement();   //初始化查询
sql   =   "insert   into   customers   (Name,   meal,)   values( ' " //插入数据
+ &