@RequestMapping("user")
public User data() {
User user = new User();
user.setAge(22);
user.setName("kt");
return user;
}
Specify request mapping method for example GET or POST based on requirement and try. @RequestMapping will be use like below.
@RequestMapping(path = "/user", method = RequestMethod.GET) OR @RequestMapping(path = "/user", method = RequestMethod.POST)