-1:Converter 一个咱们一直在使用殊不知道的接口前端
0:Converter接口 接口做用:spring
当添加了一个实现converter接口的类,并添加到spring容器时。Controller接收的数据会自动转换为想要的类型数组
1:Converter的完整路径是 mvc
org.springframework.core.convert.converter.Converter
2:使用方法 orm
public class ConverTest implements Converter<String, Date>
自定义类实现 Converter接口,String 是原始数据类型,Date是要转换的数据类型。重写convert方法,并加上@Service注解接口
好比 在重写的方法中 你用 SimpleDateFormat 把格式 2019-01-23 的数据转换date字符串
3:这时前端 传值 2019-01-23 ,就能够直接用date类型接收。 class
4:springmvc其实已经实现了许多类型转换,好比前端传 1,用 int 就能接收到,其实这就是用了自带的Converter,springmvc一样自带字符串时间转换,默认类型是 2019/01/23 ,还有字符串用“,”分隔,就能够用字符串数组接收。容器