JSP---第八次作业

截图:

 

 

 

 

 代码:

    public boolean addMail(Msg msg){
        Statement st =null;
        Connection con=null;
        try{
            //获取连接
            con = getConnection();
            //书写SQL语句
            st = con.createStatement();
            java.util.Date msg_crate_date = msg.getMsg_create_date();
            String sqlmsg_create_date = String.format("%tF", msg_crate_date);
            String sql = "insert into msg(username,title,msgcontent,state,sendto,msg_create_date) "+"values('"+msg.getUsernname()+"','"
            +msg.getTitle()+"','"
            +msg.getMsgcontent()+"','"
            +msg.getState()+"','"
            +msg.getSendto()+"','"
            +sqlmsg_create_date+"'"
            +")";
            int row = st.executeUpdate(sql);
            if(row>0){
                //发送成功
                return true;
            }
            
        }catch(SQLException e){
            e.printStackTrace();
        }finally{
            closeAll(con, st, null);
        }
        return false;
    }
<body>
 
        <form action="" method="post">
        发件人:<input type="text" name="sjr" value="ls"  readonly="readonly"/><br/>
        标    题:<input type="text" name="bt" />     <br/>
        正    文:<br/>
        <textarea rows="10" cols="30" name="zw"></textarea> <br/>
        <input type="submit" value="发送" />
        <a href="main.jsp"><input type="submit" value="返回" /></a>
    </form>
  </body>

 

posted @ 2020-05-11 16:10  破男孩儿  阅读(104)  评论(0编辑  收藏  举报