日期:2014-05-18  浏览次数:20685 次

ssh框架多文件上传中的问题
ssh框架写的项目,加多文件上传功能时,要设定设定临时文件存放目录,不然会出现这个错误:Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir。但这个项目的基于注解的零配置文件的,跟本没有struts.xml文件,不知道怎么在注解配置,求高手。。。
------解决方案--------------------
应该还是文件的读写,然后指定目录。
------解决方案--------------------
<!-- Sample file upload stack -->
            <interceptor-stack name="fileUploadStack">
                <interceptor-ref name="fileUpload"/>
                <interceptor-ref name="basicStack"/>
            </interceptor-stack>

我看了下 struts jar包 ,也许这2个拦截器是突破口 你这种只能直接修改struts源码。。。或者修改 struts-default.xml 
------解决方案--------------------
零配置好像也是需要struts.xml的,毕竟零配置又不是无配置。
你也可以在上传的时候自己创建临时文件夹,然后指定路径上传到你的文件夹,参考一下:

//File pic; String picFileName;  多文件上传改成数组.

newName = UUID.randomUUID().toString() + "."+ FilenameUtils.getExtension(yspicFileName);
String patns = ServletActionContext.getRequest().getRealPath("") + "/temp";
File dir = new File(patns);
if (!dir.exists())
dir.mkdirs();
File f = new File(dir, newName);
FileUtils.copyFile(yspic, f);

------解决方案--------------------
没有struts.xml,就用hibernate.cfg.xml 或 applicationContext.xml 来重新设置注解。
------解决方案--------------------
没有struts.xml,可能会有struts.properties文件。

不然就自己创建一个struts.xml文件
------解决方案--------------------
那只是告警吧,不设置,容器会默认用一个临时存放的路径的
------解决方案--------------------
http://pan.baidu.com/s/13rW2y
我用的uploadify写的一个小例子!
------解决方案--------------------
后台对象是你处理的。根本用不到临时路劲,这是uploadify自身要用的。

参考http://blog.csdn.net/withiter/article/details/7272338