smartupload为什么使用smartupload执行上传保存操作时用这句smart.save("upload")失败用smart.save("/upload")成功

smartupload  时间:2021-07-02  阅读:()

jspsmartupload.jar怎么用啊?

我以前项目使用过,但是后来被摒弃了,因为jspsmartupload.jar已经很久没有更新,而且它在上传大文件时会有问题 建议使mons-fileupload.jar(另外需mons-io.jar) 下面为部分源代码: /**Create a factory for disk-based file items*/ DiskFileItemFactory factory = new DiskFileItemFactory(); /**设置最大的内存大小*/ factory.setSizeThreshold(4096); /**创建一个新的文件上传操作*/ ServletFileUpload upload = new ServletFileUpload(factory); /**设置能上传的最大文件的大小*/ upload.setSizeMax(10*1024); /**Parse the request*/ List fileItems = upload.parseRequest(request); //开始读取上传信息 Iterator iter = fileItems.iterator(); // 依次处理每个上传的文件 while(iter.hasNext()) { FileItem item = (FileItem) iter.next(); // 忽略其他不是文件域的所有表单信息 if (!item.isFormField()) { String name = item.getName(); String endName = name.substring(name.lastIndexOf(".") + 1); try{ item.write(new File(request.getRealPath("\"+sUploadDir+FileName+"."+ endName))); }catch(Exception e){ e.printStackTrace(); }

SmartUpload中文乱码如何解决???文件名的在Servlet中提取。

中文乱码问题 你可以使用一个转中文的工具类,在我的空间里也有。

很方便。

打包为.jar文件的话,也需要个工具类。



算了 我直接贴这吧。

方便后来人也 jar包的话 你去下mons-io-1.2.jar 就行了。

以下是ZIP工具类~ ------------------------------------------ import java.io.*; import java.util.Enumeration; import java.util.zip.*; mons.io.FilenameUtils; /** * zip压缩工具。

暂不支持中文文件名。

* * @author zhangjin * */ public class ZipUtils { public static void main(String[] args) { long start = System.currentTimeMillis(); zip("D:/bak", "D:/test.zip"); // System.out.println(System.currentTimeMillis() - start); // start = System.currentTimeMillis(); // unzip("d:\test.zip", "d:\hoho"); System.out.println(getCRCCode("D:\sessionserver.jar")); System.out.println(System.currentTimeMillis() - start); } public static final int DATA_BUFFER = 8192; /** * 获得crc签名。

* @param filename * @return */ public static String getCRCCode(String filename){ String code = ""; try{ FileInputStream fileinputstream = new FileInputStream(filename); CRC32 crc32 = new CRC32(); CheckedInputStream checkedinputstream = new CheckedInputStream(fileinputstream, crc32); byte data[] = new byte[DATA_BUFFER]; while (checkedinputstream.read(data, 0, DATA_BUFFER)!=-1){} code = Long.toHexString(crc32.getValue()); } catch (Exception e) { e.printStackTrace(); } return code; } /** * 压缩文件,只处理一层目录,不处理多层目录。

* * @param srcdir * @param filename */ public static void zip(String srcdir, String filename) { try { //如果目录不存在,创建目录 String filepath = FilenameUtils.getFullPath(filename); File zippath = new File(filepath); if (!zippath.exists()) zippath.mkdirs(); ZipOutputStream out = new ZipOutputStream(new DataOutputStream( new FileOutputStream(filename))); subzip(srcdir, "", out); out.close(); } catch (Exception e) { e.printStackTrace(); } } /** * 递归处理多级目录。

* * @param srcdir * @param subdir * @param out * @throws Exception */ private static void subzip(String srcdir, String subdir, ZipOutputStream out) throws Exception { subdir = subdir.equals("") ? "" : (subdir.startsWith(File.separator) ? subdir : File.separator + subdir); File dirfile = new File(srcdir + subdir); // System.out.println(srcdir+subdir); String[] files = dirfile.list(); String subname = ""; for (int i = 0; i < files.length; i++) { subname = srcdir + subdir + File.separator + files[i]; if (new File(subname).isDirectory()) { subzip(srcdir, subdir + File.separator + files[i], out); } else { BufferedInputStream in = new BufferedInputStream( new FileInputStream(subname), DATA_BUFFER); out.putNextEntry(new ZipEntry((subdir.equals("") ? "" : (subdir .startsWith(File.separator) ? subdir.substring(1, subdir.length()) + File.separator : subdir + File.separator)) + files[i])); int count; byte data[] = new byte[DATA_BUFFER]; while ((count = in.read(data, 0, DATA_BUFFER)) != -1) { out.write(data, 0, count); } in.close(); } } } /** * 解压缩文件。

* * @param filename * @param destdir */ public static void unzip(String filename, String destdir) { try { BufferedOutputStream dest = null; BufferedInputStream is = null; ZipEntry entry; ZipFile zipfile = new ZipFile(filename); Enumeration e = zipfile.entries(); while (e.hasMoreElements()) { entry = (ZipEntry) e.nextElement(); // System.out.println("Extracting: " + entry); is = new BufferedInputStream(zipfile.getInputStream(entry)); int count; byte data[] = new byte[DATA_BUFFER]; // 检查目录,强制建立。

String zipedfilename = destdir + File.separator + entry.getName(); String zipedfilepath = FilenameUtils.getFullPath(zipedfilename); File zipedpath = new File(zipedfilepath); if (!zipedpath.exists()) zipedpath.mkdirs(); FileOutputStream fos = new FileOutputStream(zipedfilename); dest = new BufferedOutputStream(fos, DATA_BUFFER); while ((count = is.read(data, 0, DATA_BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); is.close(); } } catch (Exception e) { e.printStackTrace(); } } }

smartupload.jar放的路径到底是什么?

1. 不用把jar文件里面的Class解压到WEB-INF/classes,先把这些删除了吧。

2. 下载servletAPI.jar 3. 设置你的在eclipse中,ClassPath。

JspSmartUpload上传组件有哪些特点

SmartUpload 是一个免费的上传下载组件,好像早已经停止开发了。

SmartUpload.jar:我找到的最好的一个jar包,对于编码为GBK的,完全支持中文名文件的上传与下载;但对于UTF-8的,中文名上传可以,但中文名下载还是乱码。

这个组件,小项目用用还行,对于大项目,不建议使用。

比较常用的有mons-fileupload等,而且许多框架都集成了上传下载功能,如Struts 1/ Struts 2 另外,注意一点:由于smartupload是把文件全部缓存到内存里,所以上传大文件或多文件时就有可能出错,建议一般不要超过20M,个数也不要太多

如何使用jspsmartupload

jspSmartUpload太小巧,问题很多,代码共享者很早就没有再维护次小项目,建议用monupload. 下载文件不用任何组件也可以,你只要给出正确的mime type即可。

为什么使用smartupload执行上传保存操作时用这句smart.save("upload")失败用smart.save("/upload")成功

你好,smart.save(“”)方法是将文件保存到指定目录,upload 表示当前请求文件的相对路径,/upload是表示web应用根目录下的upload目录。

只要能找到upload目录都是可以的。

天上云:香港大带宽物理机服务器572元;20Mbps带宽!三网CN2线路

天上云服务器怎么样?天上云是国人商家,成都天上云网络科技有限公司,专注于香港、美国海外云服务器的产品,有多年的运维维护经验。世界这么大 靠谱最重,我们7*24H为您提供服务,贴心售后服务,安心、省事儿、稳定、靠谱。目前,天上云香港大带宽物理机服务器572元;20Mbps带宽!三网CN2线路,香港沙田数据中心!点击进入:天上云官方网站地址香港沙田数据中心!线路说明 :去程中国电信CN2 +中国联通+...

#消息# contabo:德国老牌机房新增美国“纽约、西雅图”数据中心,免设置费

运作了18年的德国老牌机房contabo在继去年4月开办了第一个美国数据中心(中部城市:圣路易斯)后立马在本月全新上马两个数据中心:纽约、西雅图。当前,为庆祝美国独立日,美国三个数据中心的VPS全部免除设置费,VPS本身的配置很高,价格适中,有较高的性价比!官方网站:https://contabo.com/en/SSD VPSKVM虚拟,纯SSD阵列,不限制流量,自带一个IPv4内存CPUSSD带...

青云互联:美国洛杉矶CN2弹性云限时八折,15元/月起,可选Windows/可自定义配置

青云互联怎么样?青云互联是一家成立于2020年6月的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,目前提供有美国免费主机、香港主机、香港服务器、美国云服务器,让您的网站高速、稳定运行。美国cn2弹性云主机限时8折起,可选1-20个IP,仅15元/月起,附8折优惠码使用!点击进入:青云互联官方网站地址青云互联优惠码:八折优惠码:ltY8sHMh (续费同价)青云互联活动方案:美国洛杉矶...

smartupload为你推荐
元数据管理请元数据管理包括哪些内容?查字网“很”去掉双人旁读什么?rdlregardless是什么意思bindservice如何启动和停止用service拓扑关系拓扑关系在GIS中的作用slideshare如何通过slideshare扩充LinkedIn人脉slideshare什么是slide sandal索引超出了数组界限求助大神什么叫索引超出了数组界限flowplayerswfobject.js这能不能播放音频啊(amr)spawningvc出现error spawning c1.exe怎么解决?
网站空间申请 台湾服务器租用 上海服务器租用 中文域名查询 vir Vultr suspended 外国域名 云主机51web 彩虹ip gg广告 圣诞促销 刀片服务器是什么 有奖调查 国外代理服务器地址 服务器是干什么的 lamp什么意思 网页加速 万网服务器 时间服务器 更多