String sql = "select id,content,mail_entity_id from mail_raw where mail_entity_id=? limit 1 ";
byte[] rawMail = (byte[]) jt.queryForObject(sql,
new Object[]{downLoadRawMaiID}, new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowid)
throws SQLException {
return rs.getBytes("content");
}
});
if (rawMail == null) {
response.setContentType("text/plain");
response.getWriter().println(
"no such mail. raw mai id is" + downLoadRawMaiID);
} else {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment; filename=" + downLoadRawMaiID + ".eml");
response.getOutputStream().write(rawMail);
}