注释类型 RestController
@Target(TYPE) @Retention(RUNTIME) @Documented @Controller @ResponseBody public @interface RestController
A convenience annotation that is itself annotated with@Controller
and@ResponseBody
.Types that carry this annotation are treated as controllers where
@RequestMapping
methods assume@ResponseBody
semantics by default.NOTE:
@RestController
is processed if an appropriateHandlerMapping
-HandlerAdapter
pair is configured such as theRequestMappingHandlerMapping
-RequestMappingHandlerAdapter
pair which are the default in the MVC Java config and the MVC namespace. In particular@RestController
is not supported with theDefaultAnnotationHandlerMapping
-AnnotationMethodHandlerAdapter
pair both of which are also deprecated.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Sam Brannen