spring接收请求行参数,转换数据格式的方法
@Bean public Converter<String, LocalDateTime> localDateTimeConverter() { return new Converter<String, LocalDateTime>() { @Override public LocalDateTime convert(String source) { return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(pattern)); } }; }
将 Converter<S, T>方法注册成spring终端bean。S为前台传递的类型,T为后台接收的类型。
上面的bean可以将前台传递的字符串类型,转成后台LocalDateTime类型需要的格式。
欺骗自己最简单,欺骗自己最困难。
安慰自己最简单,安慰自己最困难。
浙公网安备 33010602011771号