SpringMVC_自定义类型转换器(springboot)
@Configuration public class WebMvcConfig implements WebMvcConfigurer{ @Override public void addFormatters(FormatterRegistry registry){ Converter<String,Person> personConverter = new Converter<String,Person>(){ @Override public Person convert(String content){ Person person = new Person(); String[] split = content.split(","); person.setName(split[0]); person.setAge(Integer.parseInt(split[1])); person.setSex(split[2]); return person; } }; registry.addConverter(personConverter); } }