2

I am using Struts in my j2ee project. I have to upload a file my jsp in simple form is this

<html:form action="/MerchantComplaintAdd" method="post" enctype="multipart/form-data">
<html:file property="file" size="50" />
<html:submit styleClass="FormButton" >Save</html:submit>&nbsp;
</html:form>

My struts-config for this form is

<form-bean name="MerchantComplaintFormAdd"
type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="file" type="org.apache.struts.upload.CommonsMultipartRequestHandler"> 

When i view my jsp page its look fine but when i submit the form i got following exception

org.apache.commons.beanutils.ConversionException: Cannot assign value of type 'org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile' to property 'file' of type 'org.apache.struts.upload.CommonsMultipartRequestHandler'
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:422)
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1733)
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:805)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

Can you tell me what is wrong with my configuration in struts-config file??

4

1 に答える 1

4

http://www.mkyong.com/struts/struts-file-upload-example/

この線

<form-property name="file" type="org.apache.struts.upload.CommonsMultipartRequestHandler">

になります

<form-property name="file" type="org.apache.struts.upload.FormFile"> 
于 2013-07-18T08:15:49.703 に答える