---
title: "【转】struts ActionForm数据类型不匹配"
author: "wangyanlong0107"
date: "2012-08-09T16:03:02Z"
tags: []
categories: ["企业架构"]
slug: "struts-actionform"
draft: false
lastmod: "2012-08-09T16:03:02Z"
id: 1626898
url: "https://bigdragon.iteye.com/blog/1626898"
---

**报错信息：**

java.servlet.ServletException: BeanUtils.populate

java.lang.IllegalArgumentException: argument type mismach

 

**场景：**

当页面数据提交时,有时会报这样的错 ，通常jsp 点击提交按钮时没有进入action 直接抛错，配置文件信息检查都正确

 

**原因：**

BeanUtils 填充时

参数类型不匹配 的意思

 

**解决方案：**

1、struts 动态上传文件使用&lt;html:file&gt;标签时，form标签需要加 enctype="multipart/form-data" 属性设置

2、查看页面数据类型，

**例如：**form 中的字段定义成Date 类型，页面也会出错，

**可改为：**

private Date brithday;  
public String getBrithday() {  
   return new SimpleDateFormat("yyyy-MM-dd").format(brithday);  
}

public void setBrithday(String brithday) throws ParseException {  
   this.brithday = new SimpleDateFormat("yyyy-MM-dd").parse(brithday);  
}

 

转载：http://anxingyu.javaeye.com/blog/404278