When use ResponseEntity and @RestController for Spring RESTful applications

ResponseEntity is meant to represent the entire HTTP response. You can control anything that goes into it: status code, headers, and body. @ResponseBody is a marker for the HTTP response body and @ResponseStatus declares the status code of the HTTP response. @ResponseStatus isn’t very flexible. It marks the entire method so you have to be … Read more

Difference between and

<context:annotation-config> is used to activate annotations in beans already registered in the application context (no matter if they were defined with XML or by package scanning). <context:component-scan> can also do what <context:annotation-config> does but <context:component-scan> also scans packages to find and register beans within the application context. I’ll use some examples to show the differences/similarities. … Read more