我是用struts框架开发的
action中:/** 1.参数赋值给form */
form.setName(service.getName()); //String
form.setServiceCode(service.getServiceCode()); //String
form.setTopTitle(service.getTopTitle());          //String
/** LOGO的图片编号 */
form.setServiceLogoId(service.getServiceLogoId()); //int
form.setIconName(service.getIconName()); //string
form.setIconPath(service.getIconPath()); //string
form.setAdvertisement(service.getAdvertisement()); //String
form.setProvider(service.getProvider());          //String
form.setServiceIntro(service.getServiceIntro()); //String
form.setFeeIntro(service.getFeeIntro()); //string
form.setContentTypeCollectionSelect(service.getContentType()); //string
form.setCopyRight(service.getCopyRight()); //String
form.setServiceTel(service.getServiceTel()); //String
form.setServiceInterUrl(service.getServiceInterUrl()); //String
form.setServiceSubmitUrl(service.getServiceSubmitUrl()); //String
form.setServiceFeeUrl(service.getServiceFeeUrl()); //String
form.setStatus(service.getStatus()); //String
form.setAddAdmin(service.getAddAdmin()); //String
form.setAddTime(service.getAddTime()); //Date

解决方案 »

  1.   

    你提交过去的都是字符串形式的.
    赋给form的也是String 型的---
    你的service和form分别指什么?
      

  2.   

    其中有两个是int,Date型的
    form.setAddTime(service.getAddTime()); //Date
    form.setServiceLogoId(service.getServiceLogoId()); //intservice是一个实体对象,form是页面表单
    在action中把值赋值给form表单,然后转向到页面,页面就能直接从form表单的值显示出来的.
      

  3.   

    String不可直接Cast为日期. 
    actionform中最好只用string类型,使用日期,需要自己来完成转化。
      

  4.   

    1.继承 ActionForm 的类的所有字段必须为 String 型
    2.由于 Date 型转换为 String 需设置 DateFormat ,所以你 Bean 里的日期字段最好用 String 这样就不会出现类型转换错误了。
      

  5.   

    http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/package-summary.html#conversion
    看看这个api吧,说的很清楚的
      

  6.   

    TO: wender(行者) 
    1.继承 ActionForm 的类的所有字段必须为 String 型??ActionForm 的类的所有字段可以为其它的类型,其它类型不能直接作为页面的text/areatext/hide属性。
    例如可以为ArrayList/String[]都可以的,不过这时不能直接当作页面的text/areatext/hide属性而已。
      

  7.   

    ActionForm不同类型域,在jsp中有相应的tag,看一下,很好用。