Can someone point out the differences between the 2 and when it is appropriate to use which one?
@ServerEndPoint
is an annotation for the web socket, and @Controller
is an annotation for the web. (Similarly there is @RestController
.)
Maybe this article can help:
https://spring.io/blog/2013/05/23/spring-framework-4-0-m1-websocket-support
@ServerEndpoint: If decorated with @ServerEndpoint, the container ensures availability of the class as a WebSocket server listening to a specific URI space
@ServerEndpoint(value="/chat/{username}")
public class ChatEndpoint {
----
}
@Controller: If decorated with @Controller annotation is an annotation used in Spring MVC framework (the component of Spring Framework used to implement Web Application). The @Controller annotation indicates that a particular class serves the role of a controller. The @Controller annotation acts as a stereotype for the annotated class, indicating its role. The dispatcher scans such annotated classes for mapped methods and detects @RequestMapping annotations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With