springmvc配置文件

    
        
        
            
        
    

org.springframework.format.support.FormattingConversionServiceFactoryBean

spring提供的converter的对外接口,可以注入自己写的converter转换器

需要向处理器适配器中注入自定义的参数绑定组件,本例接口在注解驱动

conversion-service="conversionService"

自定义的日期转换器

package converter;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;import org.springframework.core.convert.converter.Converter;public class CustomDateConverter implements Converter
 {    @Override    public Date convert(String source) {        //实现将日期串转换成日期类型,格式是yyyy-MM-dd HH:mm:ss        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");        try {                        return simpleDateFormat.parse(source);        } catch (ParseException e) {            e.printStackTrace();        }        return null;    }}