<form action="<c:url value='/MailServlet?method=addMail' />" method="post"> 收件人:<input type="text" name="sjr" value="${sessionScope.fjr }" readonly="readonly"/><br/> 标 题:<input type="text" name="bt" /> <br/> 正 文:<br/> <textarea rows="10" cols="30" name="zw"></textarea> <br/> <input type="submit" value="发送" /> </form>
public void addMail(Mail mail) { try { String sql = "INSERT INTO msg(username,title,msgcontent,state,sendto,msg_create_date) VALUES(?,?,?,?,?,?)"; Object[] params = { mail.getUsername(), mail.getTitle(), mail.getMsgcontent(), mail.getState(), mail.getSendto(), mail.getMsg_create_date() }; qr.update(sql, params); } catch (SQLException e) { throw new RuntimeException(e); } }