如何接收有附件的邮件??? 没试过,友情Up 将“流氓无赖”测试到底 ——始于2003年7月 树欲止而风不停,行云流水匆匆去; 树梢蚂蚱凭空望,江边浪花碎巨石; 支持“流金岁月”!!! ——2003年12月24日am^@^ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //下载 public String getdocumentomage(String id, String path) { if (id == null || id.equals("")) { return "null"; } File f = new File(path); if (f.exists()) { return "exists"; } String sql = ""; sql = "select * from TB_IMAGE WHERE document_image_id=" + id; try { Statement pstmt; pstmt = con.createStatement(); ResultSet rr = pstmt.executeQuery(sql); if (rr.next()) { byte[] img = rr.getBytes("CONTENT"); File ff = new File(path); try { FileOutputStream out = new FileOutputStream(ff); out.write(img); out.close(); } catch (java.io.FileNotFoundException e1) { path = "file not found:" + e1.getMessage(); } } rr.close(); pstmt.close(); return path; } catch (Exception e) { return "error"; } }//下载附件调用上边bean rs=op.getdb("select * from tb_image where document_id); while(rs.next()) { String documentimageid=rs.getString("document_image_id"); String url=rs.getString("url").trim(); String title2=rs.getString("title"); String srcpath=request.getContextPath()+documentimageid+url; String realpath=request.getRealPath(documentimageid+url); String slt=op.getdocumentomage(documentimageid,realpath);//创建文件} 楼主:如果附件为中文时会出错,英文不会,等待解决;如果附件大小为0k时会出错,加一个判断: int chunk = part.getSize(); if (chunk<0)//如果附件大小为空则为0 chunk=0; byte[] buffer = new byte[chunk]; 楼主:如果附件名称为中文时会出错,英文不会,等待解决;如果附件大小为0k时会出错,加一个判断: int chunk = part.getSize(); if (chunk<0)//如果附件大小为空则为0 chunk=0; byte[] buffer = new byte[chunk]; struts2 jsp如何显示list中的list中的数据。 ssh2框架整合遇到问题。 紧急求解 关于web的简单问题 访问数据库 网页内不嵌如播放器能播放歌曲吗? 急!jfreechart 在linux下出错 在线等 也问一个有关applet不显示的问题 问个SQL语法的问题 关于jsp页中form表单提交的问题?(在线等!高分求救!) JSP连不上SQL Server。请大虾们帮忙呀! 关于日期的问题?
public String getdocumentomage(String id, String path) { if (id == null || id.equals("")) {
return "null";
}
File f = new File(path);
if (f.exists()) {
return "exists";
}
String sql = ""; sql = "select * from TB_IMAGE WHERE document_image_id=" + id;
try {
Statement pstmt;
pstmt = con.createStatement();
ResultSet rr = pstmt.executeQuery(sql);
if (rr.next()) {
byte[] img = rr.getBytes("CONTENT");
File ff = new File(path);
try {
FileOutputStream out = new FileOutputStream(ff);
out.write(img);
out.close();
}
catch (java.io.FileNotFoundException e1) {
path = "file not found:" + e1.getMessage();
}
}
rr.close();
pstmt.close();
return path;
}
catch (Exception e) {
return "error";
}
}//下载附件调用上边bean
rs=op.getdb("select * from tb_image where document_id);
while(rs.next())
{ String documentimageid=rs.getString("document_image_id");
String url=rs.getString("url").trim();
String title2=rs.getString("title");
String srcpath=request.getContextPath()+documentimageid+url;
String realpath=request.getRealPath(documentimageid+url);
String slt=op.getdocumentomage(documentimageid,realpath);//创建文件
}
加一个判断:
int chunk = part.getSize();
if (chunk<0)//如果附件大小为空则为0
chunk=0;
byte[] buffer = new byte[chunk];
加一个判断:
int chunk = part.getSize();
if (chunk<0)//如果附件大小为空则为0
chunk=0;
byte[] buffer = new byte[chunk];