免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
解決struts多文件上傳出現(xiàn)的問題
This topic has 9 replies on 1 page.   
 

Multiple form upload
Author: pperliti  Posts: 5   Registered: 4/29/02   Jul 19, 2004 12:21 PM   
 

Hi everybody.
I‘m trying to use a form to upload several files, all at once.
I use Struts and Commons facilities (that is the FormFile interface).
Here‘s my action form:

public class AttachmentForm
extends ActionForm {

/* Files to upload */
private FormFile[] uploadedFiles;

public FormFile[] getUploadedFiles() {
return uploadedFiles;
}

public void setUploadedFiles(FormFile[] uploadedFiles) {
this.uploadedFiles = uploadedFiles;

}

And this is the html code I use to populate the action form (I‘m using Velocity, but I don‘t think this is really important):


...
<form name="uploadForm" method="post" enctype="multipart/form-data" action="(...my action...)">
...
Attachment 1: <input type="file" name="uploadedFiles"/>
Attachment 2: <input type="file" name="uploadedFiles"/>
Attachment 3: <input type="file" name="uploadedFiles"/>
...
</form>
...

 

Everytime I submit the form I obtain this exception:

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 


java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

If I adjust the java source to manage one file only (ie. FileForm instead of FileForm[]) it works, but as I try to use an array I get the Exception.
I use struts 1.1 on Windows XP platform and Tomcat 5.0.24.
Have you got any ideas? Is it a bug of commons-beanutils?
Thanks in advance,
Paul
 

Re: Multiple form upload
Author: Spit  Posts: 1   Registered: 4/20/05   Apr 20, 2005 7:40 AM (reply 1 of 9)   
 

Hello, I have the same problem, if you discovery any solution please email me.
Thanks, Sim&atilde;o Castro
 

Re: Multiple form upload
Author: vbatista  Posts: 11   Registered: 5/29/98   Apr 21, 2005 2:35 AM (reply 2 of 9)   
 

Hi!
I am having the same error. I need to upload N files, being N dynamic between requests.
Have you solved your problem?
Any hint would be appreciated.

Regards,
Victor Batista
 

Re: Multiple form upload
Author: mshanu  Posts: 488   Registered: 3/24/05   Apr 21, 2005 3:57 AM (reply 3 of 9)   
 

Attachment 1: <input type="file" name="uploadedFiles"/>
Attachment 2: <input type="file" name="uploadedFiles"/>
Attachment 3: <input type="file" name="uploadedFiles"/>
give unique names to the name of the file fields..

regards
shanu
 

Re: Multiple form upload
Author: vbatista  Posts: 11   Registered: 5/29/98   Apr 21, 2005 5:16 AM (reply 4 of 9)   
 

Hi!
Thks for your reply.
If I define mutiple file inputs :

<input type="file" name="uploadFile" ...
><input type="file" name="uploadFile" ...
...

and define a variable on the Struts form like;
private FormFile[] uploadFile = null;

Struts throws the exception below while trying to fill the array.
I can fill arrays of Strings, ints,....but with the FormFile I am having this Exception. I would prefer to use Struts mechanism to upload files instead of doing things "manually". Any help would be appreciated.

Thanks in advance,
Victor Batista


13:07:38,603 ERROR [Engine] StandardWrapperValve[struts]: Servlet.service() for
servlet struts threw exception
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(Property
Utils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(Property
Utils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.
java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:101
9)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProc
essor.java:798)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:205)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
4)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at pt.ptinovacao.dino.admin.servlet.filter.StrutsFilter.doFilter(StrutsF
ilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at pt.ptinovacao.dino.admin.servlet.filter.DefaultFilter.doFilter(Defaul
tFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:66)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:150)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:462)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:54)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
535)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)>
 

Re: Multiple form upload
Author: linxpda  Posts: 651   Registered: 12/26/04   Apr 21, 2005 10:12 AM (reply 5 of 9)   
 

Instead of this:

Attachment 1: <input type="file" name="uploadedFiles"/>
Attachment 2: <input type="file" name="uploadedFiles"/>
Attachment 3: <input type="file" name="uploadedFiles"/>

use this and try it:

Attachment 1: <input type="file" name="attachment1"/>
Attachment 2: <input type="file" name="attachment2"/>
Attachment 3: <input type="file" name="attachment3"/>

You‘re uploading three files, all with the same request parameter name. Heck, that would cause me to bust a blood vessel.
 


Re: Multiple form upload
Author: romano_nj  Posts: 1   Registered: 6/16/05   Jun 16, 2005 12:29 PM (reply 9 of 9)   
 
======================= 從這里開始 ==============================
I‘ve been battling this for some time now and here is how you get around it:

Jsp page:
<html:file property=‘<%="referenceFormFile["+i+"]"%>‘ size="40"/>
(注意是帶[])
where i is some counter generated by for loop or iterator

Action form:
Create property -> private FormFile[] referenceFormFile;

Add the following methods:
public FormFile[] getReferenceFormFile()
{
return referenceFormFile;
}

public void setReferenceFormFile(FormFile[] referenceFormFile)
{
this.referenceFormFile = referenceFormFile;
}

public FormFile getReference(int index) 

return referenceFormFile[index];
}

public void setReference(int index,FormFile reference) 

referenceFormFile[index] = reference;
}

Make sure to initialize array within reset method and on load

I did it this way:
/**
* initialize array of file upload
* @param request
*/
public void initArray(HttpServletRequest request)
{
referenceFormFile = new FormFile[MAX_NUMBER_REFERENCES];
}

Make sure you call it from reset method and when action form is created

Hope it helps,
Sincerely Roman
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
struts2 報(bào)錯(cuò):freemarker.log.JDK14LoggerFactory$JDK14Logger error
struts 報(bào)錯(cuò)
java.lang.NullPointerException: Module 'null' not found
異步AJAX可能引起的ResponseFacade.sendError
Spring 注入錯(cuò)誤
No Dialect mapping for JDBC type 錯(cuò)誤分析
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服