展开全部
获取表单62616964757a686964616fe78988e69d8331333365643536中的信息,然后插入到Mysql中
pageEncoding="gbk"%>
html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
int id = Integer.parseInt(request.getParameter("id"));
int rootid = Integer.parseInt(request.getParameter("rootid"));
%>
Replay">
">
---------------------------------------------------------------
下面接收上面表单中传过来的信息,并插入到mysql中
pageEncoding="gbk"%>
html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
request.setCharacterEncoding("GBK");
int id = Integer.parseInt(request.getParameter("id"));
int rootid = Integer.parseInt(request.getParameter("rootid"));
String title = request.getParameter("title");
String cont = request.getParameter("cont").replaceAll("\n","
");
Connection conn = null;
Statement st = null;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/bbs?user=root&password=690115399");
st = conn.createStatement();
conn.setAutoCommit(false);
String sql = "insert into article values(null,?,?,?,?,now(),0)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1,id);
pstmt.setInt(2,rootid);
pstmt.setString(3,title);
pstmt.setString(4,cont);
pstmt.executeUpdate();
st.executeUpdate("update article set isleaf = 1 where id = " + id);
conn.commit();
conn.setAutoCommit(true);
st.close();
pstmt.close();
conn.close();
%>
Insert title here当然最好的方法还是应该用jsp + JavaBean方式。