struts2自定义局类型型转换器

struts2自定义局部类型转换器

1、新建class.使之继承DefaultTypeConverter

2、右键->source->Overrides/impletments methods实现父类方法:

@Override
	public Object convertValue(Map<String, Object> context, Object value,
			Class toType) {
		// TODO Auto-generated method stub
...
 return super.convertValue(context, value, toType);
	}

3、将上面的类型转换器注册为局部类型转换器:

在Action包下放置HelloWorldAction-conversion.propertites文件,在此文件中的内容是:

属性名称=类型转换器的全类名

birthday = com.feng.type.Converter.DateTypeConverter