Struts 2 和 YUI Uploader 问题
我正在开发一个项目,我们需要能够一次选择多个文件进行上传。由于我们已经将 YUI 用于其他一些事情,这似乎是一个相当简单的请求。我做了一些研究并决定使用 YUI 的 Uploader 来完成这项工作。
构建了一个简单的示例来熟悉该组件。简单的示例是使用 YUI 库连接到 Servlet 的 JSP,使用 org.apache.commons.fileupload 来处理文件。工作完美无缺。所以我开始集成到我们的 struts 2 项目中。一切都很好,直到您尝试上传,然后它什么也不做。所以我尝试了几件事,这就是我的发现。
如果我为 YUI 编写上传函数,就像这个
函数 upload() { //alert("上传; fileID=" + fileID);
if(fileID !=null)
{
uploader.uploadAll( "http://localhost:8080/YUIUploaderTest/uploader","POST");
}
}
它工作完美。文件被上传和创建,群众欢欣鼓舞。
但是,如果我将其更改为生产环境应有的内容,
function upload()
{
//alert("upload; fileID=" + fileID);
if(fileID !=null)
{
uploader.uploadAll( "/ECMS/certificate/massimportcertificate_uploadFiles.action","POST");
}
}
除了从闪存中抛出 #2038 错误之外,它什么也不做。经过多次谷歌搜索后,我认为也许我试图传递的网址不正确。但是,如果我将该网址放入浏览器中,并附加 http://localhost:8080/ ,它就会触发的行动。
问题是,是什么原因导致了这个2038错误呢?在 YUI 上传器工作之前,struts 中是否需要配置一些东西?
谢谢!
I have a project that I'm working on where we need to be able to select multiple files for upload at one time. Since we already use YUI for several other things this seemed to be an fairly simple request. I did some research and decided to use YUI's Uploader to do the work.
Built a simple example to get familiar with the component. The simple example was a JSP using YUI Libraries connecting to a Servlet using org.apache.commons.fileupload to handle the files. Worked flawlessly. So I moved on to integration into our struts 2 project. Everything works great until you try to upload then it does nothing. So I tried several things and here is what I found.
If I code the upload function for YUI like this
function upload()
{
//alert("upload; fileID=" + fileID);
if(fileID !=null)
{
uploader.uploadAll( "http://localhost:8080/YUIUploaderTest/uploader","POST");
}
}
It works perfectly. Files are upload and created and the masses rejoice.
If however I change it to what it should be for the production environment
function upload()
{
//alert("upload; fileID=" + fileID);
if(fileID !=null)
{
uploader.uploadAll( "/ECMS/certificate/massimportcertificate_uploadFiles.action","POST");
}
}
it does nothing except throw up a #2038 error from flash. After much googling I thought that perhaps the url I'm trying to pass is just incorrect. But if I put that url in my browser with the http://localhost:8080/ attached to it it fires off the action.
The question is, what is causing this 2038 error? Is there something in struts that needs to be configured before the YUI uploader will work?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要指定绝对路径。给出相对路径是行不通的。
希望这有帮助!
You need to specify an absolute path. Giving a relative path wont work.
Hope this helps!