Announcement Announcement Module
Collapse
No announcement yet.
Return JSON Data with Springs MVC which way is better and why? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Return JSON Data with Springs MVC which way is better and why?

    Return JSON Data with Springs MVC which way is better and why? Should I sent back ResponseEntity or just the Object?

    Code:
    @RequestMapping(value = "/", method = RequestMethod.GET)
    @ResponseBody
    public User getDisplayDefault(ModelMap model)
    {
        return new User("realname", "john smith");
    }
    vs

    Code:
    @RequestMapping(value = "/", method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<User> getDisplayDefault(ModelMap model)
    {
       return new ResponseEntity<User>(new User("realname", "john smith"), HttpStatus.NOT_FOUND);
    }
Working...
X