惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

博客园 - 可可果

Java Annotation手册 .NET环境下五种邮件发送解决方案(转载) C#中的事务处理 - 可可果 - 博客园 用JAVA实现文本形式的树状结构显示(转) Google十大搜索技巧 Javascript导出Excel的方法 - 可可果 - 博客园 理解session机制 session的工作原理(转载) Session监听 button添加链接的方法 - 可可果 - 博客园 获得select控件的文本值的方法 - 可可果 - 博客园 清除缓存的方法 - 可可果 - 博客园 Java中Excel导出时文件名乱码问题的解决 单例模式陷阱(转载) java模式中的单例模式(转载) - 可可果 - 博客园 解决用户意外退出在线列表无法及时更新问题(转载) Java开发中,试用hibernate建立关联时出现:not-null property references a null or transient value异常的原因 ListBox之间进行传值的脚本的例子,一般在添加权限,行业或者多项时可以用到 - 可可果 - 博客园 Velocity基本语法
用commons-fileupload-1.2 实现文件上传(适用于Trubine框架)
可可果 · 2008-02-22 · via 博客园 - 可可果

 1//引入这两个包,该例子适用于turbine框架下http形式上传
 2import org.apache.commons.fileupload.DiskFileUpload;
 3import org.apache.commons.fileupload.FileItem;
 4
 5import java.io.File;
 6import java.util.List;
 7
 8import javax.servlet.http.HttpServletRequest;
 9import org.apache.turbine.util.RunData;
10import org.apache.velocity.context.Context;
11
12import com.hc360.b2b.netWorker.ParamUtils;
13import com.hc360.web3ms.business.util.BusinessFactory;
14
15
16
17public void doPerform(RunData runData, Context context) throws Exception {
18    HttpServletRequest request = runData.getRequest();
19    DiskFileUpload diskFileUpload = new DiskFileUpload();
20    // 允许文件最大长度,设置上传文件最大为 100M
21    diskFileUpload.setSizeMax(100 * 1024 * 1024);
22    // 设置内存缓冲大小
23    diskFileUpload.setSizeThreshold(4096);
24    // 设置临时目录,该目录是上传数据流超过上面内存定义的大小的流存放在下面的路径上
25    diskFileUpload.setRepositoryPath(request.getRealPath("/")+"ExcelUpLoadTemp");
26    FileItem fileItem = runData.getParameters().getFileItem("fileName");//针对Turbine框架定义数据流
27    //如果没有数据流存在
28    if (fileItem.isFormField()) {
29    }
 else {
30        // 当前是一个上传的文件
31        fileItem.write(new File(request.getRealPath("/")+"ExcelUpLoadTemp/1.xls"));//指定数据流存放位置其中request.getRealPath("/")是web根目录
32    }

33}

注意,在前台HTML页面中一定要有<form id="grouptradepp_manage" method="post" action="" name="grouptradepp_manage" enctype="multipart/form-data">
而且必须要有file控件,
注意:通过二进制流的格式提交表单的时候,在Turbine框架中必须要用RunData形式获得参数,而不是requset形式,如:ParamUtils.getParameter(runData,"groupId")