You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,7 @@ This repository contains interview questions for Java developers.
103
103
-[What is the difference between @Resource and @Autowired annotations?](spring.md#what-is-the-difference-between-resource-and-autowired-annotations)
104
104
-[What is the feature in Spring Boot for setting up the dependencies?](spring.md#what-is-the-feature-in-spring-boot-for-setting-up-the-dependencies)
105
105
-[Where does Spring Boot application begin?](spring.md#where-does-spring-boot-application-begin)
106
+
-[What is the difference between @Controller and @RestController annotations?](spring.md#what-is-the-difference-between-controller-and-restcontroller-annotations)
Copy file name to clipboardExpand all lines: spring.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@
24
24
-[What is the difference between @Resource and @Autowired annotations?](#what-is-the-difference-between-resource-and-autowired-annotations)
25
25
-[What is the feature in Spring Boot for setting up the dependencies?](#what-is-the-feature-in-spring-boot-for-setting-up-the-dependencies)
26
26
-[Where does Spring Boot application begin?](#where-does-spring-boot-application-begin)
27
+
-[What is the difference between @Controller and @RestController annotations?](#what-is-the-difference-between-controller-and-restcontroller-annotations)
27
28
28
29
## How make spring service thread-safe?
29
30
There are several ways, probably too long to list here but here are a few examples:
@@ -191,4 +192,11 @@ Spring Boot application begins from dependency to Spring Boot Starter.
191
192
###### Relative links:
192
193
-https://spring.io/guides/gs/spring-boot/
193
194
195
+
## What is the difference between @Controller and @RestController annotations?
196
+
The job of @Controller is to create a Map of model object and find a view but @RestController simply return the object and object data is directly written into HTTP response as JSON or XML.
197
+
198
+
This can also be done with traditional @Controller and use @ResponseBody annotation but since this is the default behavior of RESTful Web services, Spring introduced @RestController which combined the behavior of @Controller and @ResponseBody together.
0 commit comments