Topic: struts中文件上传的问题,请高手帮忙

  Print this page

1.struts中文件上传的问题,请高手帮忙 Copy to clipboard
Posted by: death0320
Posted on: 2004-11-02 15:41

我在使用这个组件时有几个问题,请知道的朋友告之

1.我在struts下用这个组件,在form-bean这对应的jsp页面上有<html:file property="theFile"/>,那我在action中处理上传的时候,使用了commons-upload这个组件,请问如何从form-bean中取得要上传的文件用于上传?(网上看到的例子都是servlet的例子,看了半天不知道怎么和form-bean衔接起来,在form-bean里,上面的theFile是什么类型的,我看了struts自带的一个例子是使用org.apache.struts.upload.FormFile类型的,可是这个例子不是用commons-upload这个组件做的)请大虾们给个完整点的例子吧。

2.就是使用commons-upload组件时,我看网上的例子指定的都是本地的路径,请问如何指定url路径,因为做web开发当然要放在一个url路径中,请大虾告诉我

以上就是我的两个问题,搞了几天没搞明白,请高手回答我,最好给我一个小例子,非常感谢!

2.Re:struts中文件上传的问题,请高手帮忙 [Re: death0320] Copy to clipboard
Posted by: death0320
Posted on: 2004-11-03 09:23

没人知道吗?

3.Re:struts中文件上传的问题,请高手帮忙 [Re: death0320] Copy to clipboard
Posted by: dreamfield
Posted on: 2004-11-09 21:25

哥们,我也在找这个问题,共勉阿

4.Re:struts中文件上传的问题,请高手帮忙 [Re: death0320] Copy to clipboard
Posted by: lot1
Posted on: 2004-11-12 22:00

There is no magic. You have to know the upload is not as normal http request- it is multipart http request. In struts, the controller converts it into theFile class for you. In common fileupload, you can manually test the request is multipart or not, if it is, convert it into a file. You can do this in your form or action class as Struts doesnot stop you on this. Struts and common upload are the same thing regarding the file upload.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923