毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

jsp struts2一次上传多张图片代码

更新时间:2012-12-7:  来源:毕业论文
jsp struts2一次上传多张图片代码
<html> <head> <scriptlanguage="javascript"> functionaddComponent() { varuploadHTML=document.createElement("<inputtype='file' name='upload'/>"); document.getElementById("files").appendChild(uploadHTML); uploadHTML=document.createElement("<p/>"); document.getElementById("files").appendChild(uploadHTML); } </script> </head> <body> <inputtype="button"onclick="addComponent();"value="添加文件"/> <br/> <formonsubmit="returntrue;"action="/struts2/test/upload.action"method="post"enctype="multipart/form-data"> <spanid="files"><inputtype='file'name='upload'/> <p/> </span> <inputtype="submit"value="上传"/> </form> </body> </html>       importjava.io.*; importcom.opensymphony.xwork2.ActionSupport; publicclassUploadMoreActionextendsActionSupport { privatejava.util.List<File>uploads; privatejava.util.List<String>fileNames; privatejava.util.List<String>uploadContentTypes; publicjava.util.List<String>getUploadFileName() { returnfileNames; } publicvoidsetUploadFileName(java.util.List<String>fileNames) { this.fileNames=fileNames; } publicjava.util.List<File>getUpload() { returnuploads; } publicvoidsetUpload(java.util.List<File>uploads) { this.uploads=uploads; } publicvoidsetUploadContentType(java.util.List<String>contentTypes) { this.uploadContentTypes=contentTypes; } publicjava.util.List<String>getUploadContentType() { returnthis.uploadContentTypes; } publicStringexecute()throwsException { if(uploads!=null) { inti=0; for(;i<uploads.size();i++) { java.io.InputStreamis=newjava.io.FileInputStream(uploads.get(i)); java.io.OutputStreamos=newjava.io.FileOutputStream( "d:upload"+fileNames.get(i)); bytebuffer[]=newbyte[8192]; intcount=0; while((count=is.read(buffer))>0) { os.write(buffer,0,count); } os.close(); is.close(); } } returnSUCCESS; } }
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。