<body>
        <form id="form1" name="form1" method="post" action="saveArtical.jsp">
          <table width="795" border="0" cellspacing="0" cellpadding="0" height="280">
         
            <tr>
              <td align="center">文章标题:</td>
              <td><input  name="articaltitle" type="text" id="articaltitle" /><font color="red">请不要以数字开头</font></td>
            </tr>
           
            <tr>
              <td align="center">文章内容:</td>
              <td>
          <textarea id="content1" name="content1" rows="55" cols="55" ></textarea>
            </tr>
          
<tr>
           
  <td><input type="button" name="Submit" value="提交" />
  <input type="button" name="reset"value="重填" />
  </td></tr>
          </table>
         </form> <%String driverName="com.mysql.jdbc.Driver";//数据库用户名String userName="root";//密码String userPasswd="1";//数据库名String dbName="test";
String sql=null;
Statement statement;
//表名String tableName="wenzheng";//联结字符串
request.setCharacterEncoding("utf-8");
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
try{
Class.forName(driverName); Connection connection=DriverManager.getConnection(url);  statement= connection.createStatement();
String articaltitle=request.getParameter("articaltitle");
String content1=request.getParameter("content1");
 sql="insert * from "+tableName+"values('" + content1+ "','" + articaltitle+ "')";
//out.println(user+"..."+pwd);('" + content1+ "','" + articaltitle+ "')
String Submit=request.getParameter("Submit"); 
String reset=request.getParameter("reset");
out.println(articaltitle+"...."+content1+"...."+Submit);

if(Submit.equals("提交"))

statement.executeUpdate(sql);



statement.close(); 

connection.close();
}
catch(Exception e){}  %>我想把表单里面的内容提交到mysql数据库,这样实现不了,怎么去实现啊,本人不会servlet和javaBean,用jsp去实现,求助啊

解决方案 »

  1.   

    首先你的表单没提交
    <input type="button" name="Submit" value="提交" />
    改成
    <input type="submit" name="Submit" value="提交" />然后你的 insert * from 是什么东西?提交后 根据 jsp的异常信息 慢慢调试吧
      

  2.   

    2楼正解。insert语句是这样的。insert into tableName values(val1,val2,val3....);
      

  3.   

    1.在form里面,提交的那个按钮不是button类型,而是submit类型,2楼说的是对的;
    2.你的sql语句写错了,语法错误,正确写法4楼给出了