Issue
Is it possible use @Service/@Component instead of @Controller annotation in Spring MVC ( I checked this out and it doesn't work) but why?
Solution
The @Controller
annotation is a specific type that, like all spring annotations, is derived from the @Component
annotation. Note that, depending on use case, it may work, and it may not. Controller classes are often used for mapping server requests to responses.
You can view this Geeks for Geeks article for more info on when to use the @Controller
annotation. If you have @RequestMapping
annotations in your class, you will not get the same behavior with a Component as you will with Controller.
Answered By - Maxwell Omdal
Answer Checked By - Cary Denson (JavaFixing Admin)