This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes beanutils.ConversionException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "beanutils.ConversionException" Watch "beanutils.ConversionException" New topic
Author

beanutils.ConversionException

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

Where is the problem?

Here is the form.

import java.sql.Date;
import java.util.Vector;

public class InsertarForm extends ActionForm{
private Date fechaPublicacion;
private Date fechaFin;
}

the jsp.

<html:form action="insertar.do">

<td width="125" valign="top"><input name="fechaPublicacion" type="text" class="campo"></td>
<td valign="top"><input name="fechaFin" type="text" class="campo"></td>

</html:form>

struts-config

<action path="/insertar" type="stasacion.novedades.Insertar" name="InsertarForm">

Exception

(catalina.core.StandardWrapperValve:invoke) Servlet.service() para servlet action lanz� excepci�n
org.apache.commons.beanutils.ConversionException
at org.apache.commons.beanutils.converters.SqlDateConverter.convert(SqlDateConverter.java:162)
at org.apache.commons.beanutils.ConvertUtils.convert(ConvertUtils.java:379)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1001)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The commons BeanUtils used by Struts will not convert a date to a String and visa versa. Your ActionForm must represent the dates as Strings, not java.util.Date objects. If you want to use java.util.Date in your model classes, that's fine, but you must write your own code to convert between String and java.util.Date.


Merrill
Consultant, Sima Solutions
 
 
subject: beanutils.ConversionException