Is Spring annotation @Controller same as @Service?

后端 未结 9 1868
夕颜
夕颜 2020-12-12 10:40

Is Spring annotation @Controller same as @Service?

I have idea about @Controller which can be used for URL mappin

9条回答
  •  粉色の甜心
    2020-12-12 11:26

    You can declare a @service as @Controller.

    You can NOT declare an @Controller as @Service

    @Service

    It is regular. You are just declaring class as a Component.

    @Controller

    It is a little more special than Component. The dispatcher will search for @RequestMapping here. So a class annotated with @Controller, will be additionally empowered with declaring URLs through which APIs are called

提交回复
热议问题