public class User {
private long id;
//用户名
private String name;
//出生日期
private Date birth;
//关联用户
private User linkUser;
//喜欢的文章
private List<Article> favArticles=new ArrayList<>();
//下面省略Getter和Setter方法
2.Article类
public class Article {
//文章id
private long artId;
//文章名
private String artName;
//下面省略Getter和Setter方法
@RestController
public class HelloController {
@GetMapping("hello")
public Date getDate(Date birth){
System.out.println(birth);
return birth;
@PostMapping(value="showUser",produces="application/json",
consumes = "application/x-www-form-urlencoded")
public User showUser(User user){
return user;
在Postman中进行测试,注意以下设置:POST请求 -> Body -> x-www-form-urlencoded。在Body中输入参数进行测试。
* A converter converts a source object of type S to a target of type T.
* Implementations of this interface are thread-safe and can be shared.
* <p>Implementations may additionally implement {@link ConditionalConverter}.
* @author Keith Donald
* @since 3.0
* @see ConditionalConverter
* @param <S> The source type
* @param <T> The target type
public interface Converter<S, T> {
* Convert the source of type S to target type T.
* @param source the source object to convert, which must be an instance of S
* @return the converted object, which must be an instance of T
* @throws IllegalArgumentException if the source could not be converted to the desired target type
T convert(S source);
public class DateConverter implements Converter
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
* <p>Like all {@code FactoryBean} implementations, this class is suitable for
* use when configuring a Spring application context using Spring {@code <beans>}
* XML. When configuring the container with
* {@link org.springframework.context.annotation.Configuration @Configuration}
* classes, simply instantiate, configure and return the appropriate
* {@code FormattingConversionService} object from a
* {@link org.springframework.context.annotation.Bean @Bean} method.