第十二周jsp

1.实现 删除 回复邮件
2.实现阅读邮件功能:在main.jsp中点击任意邮件的标题,进入到detail.jsp显示邮件详情,包括发件人,主题,内容,时间。同时需要把邮件状态修改为已读

package shool.work.pojo;


import java.util.Date;

public class Email {

  private Integer id;
  private String sender;
  private String addressee;
  private String title;
  private String content;
  private Date time;
  private String status;

  public Email() {
  }

  public Email(Integer id, String sender, String addressee, String title, String content, Date time, String status) {
    this.id = id;
    this.sender = sender;
    this.addressee = addressee;
    this.title = title;
    this.content = content;
    this.time = time;
    this.status = status;
  }

  public Email(String sender, String addressee, String title, String content, Date time, String status) {
    this.sender = sender;
    this.addressee = addressee;
    this.title = title;
    this.content = content;
    this.time = time;
    this.status = status;
  }

  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public String getSender() {
    return sender;
  }

  public void setSender(String sender) {
    this.sender = sender;
  }

  public String getAddressee() {
    return addressee;
  }

  public void setAddressee(String addressee) {
    this.addressee = addressee;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getContent() {
    return content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  public Date getTime() {
    return time;
  }

  public void setTime(Date time) {
    this.time = time;
  }

  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
    this.status = status;
  }

  @Override
  public String toString() {
    return "EmailShow{" +
            "id=" + id +
            ", sender='" + sender + '\'' +
            ", addressee='" + addressee + '\'' +
            ", title='" + title + '\'' +
            ", content='" + content + '\'' +
            ", time=" + time +
            ", status='" + status + '\'' +
            '}';
  }
}

  

<%@ page import="shool.work.pojo.Email" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 86183
  Date: 2022/5/15
  Time: 20:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>邮箱</title>
</head>
<body>
   <table border="1px" cellpadding="20px" cellspacing="0px">
       <tr>
        <th>id</th>
       <th>发件人</th>
       <th>标题</th>
       <th>内容</th>
       <th>创建日期</th>
       <th>邮件状态</th>
       <th colspan="2">操作</th>
       </tr>
       <%
           for(Email email : (List<Email>)request.getAttribute("emailList")) {%>
       <tr>
           <td><%=email.getId()%></td>
           <td><%=email.getSender()%></td>
           <td ><a href="${pageContext.request.contextPath}/showRequsestServelt?id=<%=email.getId()%>"><%=email.getTitle()%></a></td>
           <td><%=email.getContent()%></td>
           <td><%=email.getTime()%></td>
           <td><%=email.getStatus()%></td>
           <td><a href="">回复</a> </td>
           <td><a href="">删除</a> </td>
       </tr>
       <%
           }
       %>
   </table>
</body>
</html>

  

package shool.util;

import java.sql.*;

public class DBUtil {

    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/test?serverTimezone=UTC","root","143520");
    }

    public  static void close(Connection conn, PreparedStatement ps, ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

}

  

package com.fyx.entity;

import java.util.Date;

public class Msg {
    private int msgid;
    private String username;
    private String title;
    private String msgcontent;
    private int state;
    private String sendto;
    Date msg_create_date;

    public int getMsgid() {
        return msgid;
    }

    public void setMsgid(int msgid) {
        this.msgid = msgid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMsgcontent() {
        return msgcontent;
    }

    public void setMsgcontent(String msgcontent) {
        this.msgcontent = msgcontent;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getSendto() {
        return sendto;
    }

    public void setSendto(String sendto) {
        this.sendto = sendto;
    }

    public Date getMsg_create_date() {
        return msg_create_date;
    }

    public void setMsg_create_date(Date msg_create_date) {
        this.msg_create_date = msg_create_date;
    }


    public Msg(int msgid, String username, String title, String msgcontent,
            int state, String sendto, Date msg_create_date) {
        super();
        this.msgid = msgid;
        this.username = username;
        this.title = title;
        this.msgcontent = msgcontent;
        this.state = state;
        this.sendto = sendto;
        this.msg_create_date = msg_create_date;
    }



    public Msg() {
        super();
    }

    @Override
    public String toString() {
        return "Msg [msgid=" + msgid + ", username=" + username + ", sendto=" + sendto + ", title="
                + title + ", msg_create_date=" + msg_create_date + ", state=" + state + ", msgcontent="
                + msgcontent + "]";
    }

}

  

 

 

 

 

 

 

 

posted @ 2022-05-22 21:55  monster丶易  阅读(7)  评论(0编辑  收藏  举报