Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible use @Service/@Component instead of @Controller annotation SpringMVС?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading