Controller responsebody Restcontroller Controlleradvice restcontrolleradvice
@Controller
@Target ({elementtype.type})
@Retention (retentionpolicy.runtime)
@Documented
@Component public
@ Interface Controller {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in the case of a autodetected component.
* @return The suggested component name, if any
/String value () default "";
}
@ResponseBody
is usually JSON format
Role:
The annotation is used to write the object returned by the Controller method to the body data area of the response object, after the appropriate httpmessageconverter is converted to the specified format.
Time to use:
The returned data is not a page of HTML tags, but is used by some other form of data (such as JSON, XML, etc.);
@Target ({elementtype.type, elementtype.method})
@Retention (retentionpolicy.runtime)
@Documented
Public @interface responsebody {
}
========================================== @RestController
@RestController ≈ @Controller + @ResponseBody
@java. Lang.annotation.Target ({Java.lang.annotation.ElementType.TYPE})
@java. Lang.annotation.Retention ( Java.lang.annotation.RetentionPolicy.RUNTIME)
@java. lang.annotation.Documented
@ Org.springframework.stereotype.Controller
@org. Springframework.web.bind.annotation.ResponseBody
Public @interface Restcontroller {
java.lang.String value () default "";
}
@ControllerAdvice
@ControllerAdvice Document
It is typically used to define @ExceptionHandler, @InitBinder, and @ModelAttribute methods which apply to all @RequestMappi Ng methods.
@Target ({elementtype.type})
@Retention (retentionpolicy.runtime)
@Documented
@Component public
@ Interface Controlleradvice {
@AliasFor ("Basepackages")
string[] Value () default {};
@AliasFor ("value")
string[] Basepackages () default {};
Class<?>[] Basepackageclasses () default {};
Class<?>[] Assignabletypes () default {};
class<? Extends annotation>[] annotations () default {};
}
@RestControllerAdvice
@RestControllerAdvice ≈ @ControllerAdvice + @ResponseBody
The @Target ({elementtype.type}) @Retention (retentionpolicy.runtime) @Documented @ControllerAdvice @ResponseBody
Public @interface Restcontrolleradvice {@AliasFor ("basepackages") string[] Value () default {};
@AliasFor ("value") string[] Basepackages () default {};
Class<?>[] Basepackageclasses () default {};
Class<?>[] Assignabletypes () default {}; class<?
Extends annotation>[] annotations () default {}; }