You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sairam manda <ma...@hotmail.com> on 2003/11/14 13:38:38 UTC
file upload
Hello Sir,
I am new to sturts . I want to upload a file . I am using dynaform .
these are snippets
in the dynaform I used
<form-property name="pb_file"
type="org.apache.struts.upload.FormFile"/>
and in my action class
I used the following code
FormFile file = (FormFile) form.get("pb_file");
I get the following error
org.apache.commons.beanutils.ConversionException: Cannot assign value of
type 'java.lang.String' to property 'pb_file' of type
'org.apache.struts.upload.FormFile'
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:423)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1769)
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:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
can somebody make me waware of the problem.
regards
sairam
_________________________________________________________________
Enjoy shopping online? Get this e credit card.
http://server1.msn.co.in/features/amex/ It cuts cost & adds value!
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: file upload
Posted by Caoilte O'Connor <li...@caoilte.org>.
i've not used dynaforms with fileupload so if that is the
problem I couldn't say. you could try it with a normal
formBean.
However as the problem is trying to set a formfile using a
string it looks like the problem could be in your jsp.
have you set the enctype like below,
<html:form action="/blah" enctype="multipart/form-data">
and the form property using html:file rather than html:text
<html:file property="pb_file"/>
goodluck,
c
On Friday 14 November 2003 13:38, sairam manda wrote:
> Hello Sir,
>
> I am new to sturts . I want to upload a file . I am using
> dynaform .
>
> these are snippets
> in the dynaform I used
>
>
> <form-property name="pb_file"
> type="org.apache.struts.upload.FormFile"/>
>
>
> and in my action class
> I used the following code
>
>
> FormFile file = (FormFile) form.get("pb_file");
>
> I get the following error
>
>
> org.apache.commons.beanutils.ConversionException: Cannot
> assign value of type 'java.lang.String' to property
> 'pb_file' of type 'org.apache.struts.upload.FormFile'
> org.apache.struts.action.DynaActionForm.set(DynaActionFo
>rm.java:423)
> org.apache.commons.beanutils.PropertyUtils.setSimplePrope
>rty(PropertyUtils.java:1769)
> org.apache.commons.beanutils.PropertyUtils.setNestedPrope
>rty(PropertyUtils.java:1684)
> org.apache.commons.beanutils.PropertyUtils.setProperty(Pr
>opertyUtils.java:1713)
> org.apache.commons.beanutils.BeanUtils.setProperty(BeanUt
>ils.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(Request
>Processor.java:254)
> org.apache.struts.action.ActionServlet.process(ActionServ
>let.java:1482)
> org.apache.struts.action.ActionServlet.doPost(ActionServl
>et.java:525)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:7
>63)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:8
>56)
>
>
> can somebody make me waware of the problem.
> regards
> sairam
>
> _________________________________________________________
>________ Enjoy shopping online? Get this e credit card.
> http://server1.msn.co.in/features/amex/ It cuts cost &
> adds value!
>
>
> ---------------------------------------------------------
>------------ To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org For additional
> commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org