解决方案 »
- java web项目中取值的问题
- Mysql两级分类问题
- (今天搞不定,偶即将下课)通过web方式来访问客户端本地的dll,不知用什么方法(谢谢)
- [求助]java里由于对数据库并发操作产生的问题
- 问个关于:java.io.Serializable的问题!
- 请问:局域网内的一台win2000 server的机器(不是拨号的总服务器),怎样设置可以让外网访问得到这台机上的网站?(内网可以了)
- 讨论,来者有分! 有关tomcat 加载servlet 的问题? 快来看看,很简单的哟....
- 关于取得记录总数, select count(*) as bb from ....的问题,急,在线等。
- 环境变量的问题,在win2k下我装的TOMCAT还有JDK,我要和ORACLE连接,
- 在页面上显示书名和图书简介两个字段的内容的问题:前者正常显示,而后者显示出现乱码?真奇怪!求助!谢谢!
- JQuery的.html()方法如何将取出的list填充入select的option
- 求助啊(输出界面乱码问题)
FileInputStream fis = new FileInputStream(upload.get(i));
FileOutputStream fos = new FileOutputStream(savePath);//保存的时候加上uploadFileName.get(i)才对。
/**
*
*/
private static final long serialVersionUID = 3258740595336733237L;
private File[] upload;
private String[] uploadFileName; public String execute() throws IOException {
for (int i = 0; i < upload.length; i++) {
System.out.println(uploadFileName[i]);
String savePath = new String("D:/upload/" + uploadFileName[i]);
System.out.println(savePath);
FileUtils.copyFile(upload[i], new File(savePath));
}
return SUCCESS;
} /**
* @return the upload
*/
public File[] getUpload() {
return upload;
} /**
* @param upload the upload to set
*/
public void setUpload(File[] upload) {
this.upload = upload;
} /**
* @return the uploadFileName
*/
public String[] getUploadFileName() {
return uploadFileName;
} /**
* @param uploadFileName the uploadFileName to set
*/
public void setUploadFileName(String[] uploadFileName) {
this.uploadFileName = uploadFileName;
}
}
http://www.cnblogs.com/linjiqin/archive/2011/03/21/1990688.html
public String doUpload() throws IOException {
for (int i = 0; i < upload.size(); i++) {
System.out.println(uploadFileName.get(i));
String uploadPath= ServletActionContext.getServletContext().getRealPath("/upload/");
File file = new File( uploadPath);
if(!file.exists()){
file.mkdir();
}
String savePath =uploadPath +File.separator+ uploadFileName.get(i);
FileInputStream fis = new FileInputStream(upload.get(i));
FileOutputStream fos = new FileOutputStream(savePath);
IOUtils.copy(fis, fos);
fos.flush();
fis.close();
fos.close();
}
return SUCCESS;
}