自定义全局类型转换器: public Object convertValue(Mapcontext, Object value, Class toType) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); try { if (toType == Date.class) {// 要转换的参数类型value(birthday),toType(Date) // 把参数转成字符串数组,再把字符串数据转换成Date类型 String[] params = (String[]) value; return dateFormat.parse(params[0]); } else if (toType == String.class) {// 要转换的参数类型value(birthday),toType(Date) // 把参数转成Date类型,再把Date类型转成字符串 Date date = (Date) value; System.out.println(date+"String.class:" + toType.getClass()); return dateFormat.format(date); } } catch (Exception e) { } return null; } 将上面的类型转换器注册为全局类型转换器: 在WEB-INF/classes下放置xwork-conversion.properties文件。在properties 文件中的内容为: 待转换的类型=类型转换器的全类名 对于本例而言,xwork-conversion.properties文件中的内容为: java.util.Date=cn.itcast.e_action.DateTypeConverter