前台传json数据时后台springboot出错

**

2018-10-30 23:00:51.526 WARN 11484 — [nio-8080-exec-3]
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved
[org.springframework.web.HttpMediaTypeNotSupportedException: Content
type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported]

**
前台:‘content-type’: ‘application/json’
后台:在接收参数前加上@RequestBody

public void register(@RequestBody User user){

    mongoTemplate.insert(user);

}

你可能感兴趣的:(springboot)