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

推荐订阅源

S
Security @ Cisco Blogs
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Project Zero
Project Zero
C
CERT Recently Published Vulnerability Notes
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cisco Blogs
博客园 - 司徒正美
L
LINUX DO - 热门话题
D
Docker
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
Jina AI
Jina AI
Last Week in AI
Last Week in AI
Security Latest
Security Latest
The Hacker News
The Hacker News
L
Lohrmann on Cybersecurity
Y
Y Combinator Blog
A
Arctic Wolf
小众软件
小众软件
T
Threat Research - Cisco Blogs
Know Your Adversary
Know Your Adversary
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
腾讯CDC
Google DeepMind News
Google DeepMind News
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 叶小钗
I
Intezer
NISL@THU
NISL@THU
A
About on SuperTechFans
爱范儿
爱范儿
C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
G
Google Developers Blog
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news

博客园 - 摆渡人 外婆桥!

此BLOG不再继续了,请访问http://www.blogjava.net/swingboat 在Oracle中,快速获取一个部门以及它下面所有的子部门的方法。 cache模式的两种构成方式 OsWorkFlow学习(FSM:有限状态机) OsWorkFlow学习(概念) OsWorkFlow学习(数据库设置) 知识 企业如何确定是否需要BPM(出自:计世网) jsp页面,以excel的方式输出 - 摆渡人 外婆桥! - 博客园 在jboss4环境下,URL查询参数中支持中文 - 摆渡人 外婆桥! - 博客园 使用Junit时源代码和测试代码的组织(摘自Daping_Zhang 的 Blog ) junit的使用 利用html中的div标签实现网页中某一块区域的自动滚动 struts及jstl使用问题集(一) 在struts框架下实现文件的上传 利用jspsmartupload上传文件,当我不选择文件就直接上传,会有什么结果呢?一个字“惨”啊! 软件工程中的经典案例! 利用edtftpj组件实现FTP文件的上传。 含有中文字符串的截取问题!
在struts1.1框架下,利用smartupload实现文件的上传(可以是多个文件)
摆渡人 外婆桥! · 2005-05-25 · via 博客园 - 摆渡人 外婆桥!

1、前端页面upload.jsp,后台处理程序UplodAction.java
2、struts.config的配置参数如下(没有设置ActionForm):
<action input="/upload.jsp"  path="/save" scope="request" type="yhp.test.web.UploadAction" validate="false">
      <forward name="success" path="/list.do" />
    </action>
3、upload.jsp页面中主要部分代码
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html:html>
<head>
<title> 测试Struts利用SmartUpload上传文件 </title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<html:form action="/save.do" styleId="formItem" method="post"  enctype="multipart/form-data">
<html:hidden property="id"/>
<html:file property="serverpath" styleClass="input-text"></html:file>
</html:form>
</body>
</html:html>
4、UploadAction.java
import com.jspsmart.upload.File;
import com.jspsmart.upload.Files;
import com.jspsmart.upload.SmartUpload;

public ActionForward doBatchsave(ActionMapping actionMapping,
   ActionForm actionForm, HttpServletRequest httpServletRequest,
   HttpServletResponse httpServletResponse) throws Exception {
SmartUpload mySmartUpload = new SmartUpload();
  mySmartUpload.initialize(getServlet().getServletConfig(),httpServletRequest, httpServletResponse);  
  mySmartUpload.upload();
  //获取除文件以外的相关信息,例如upload.jsp中隐藏控件id的值
  String strId=(String)mySmartUpload.getRequest().getParameter("id");
  Files files=mySmartUpload.getFiles();
  Collection col=files.getCollection();
  Iterator it=col.iterator();
  while(it.hasNext()){
    File file=(File)it.next();    
    String oldFileName=file.getFileName();     
    String extname=file.getFileExt();
    String fileName=Sequence.getSequence()+"."+extname;//产生一个唯一的文件名
    file.saveAs("c:\\temp\"+fileName);    
  }
  return (actionMapping.findForward("success"));