주석 @GetMapping과 @RequestMapping의 차이점 (method = RequestMethod.GET)
차이 무엇 @GetMapping
과 @RequestMapping(method = RequestMethod.GET)
?
좀 봄 반응성 예에서 본 적이 @GetMapping
대신 사용@RequestMapping
@GetMapping
에 대한 단축키 역할을하는 구성된 주석입니다 @RequestMapping(method = RequestMethod.GET)
.
@GetMapping
새로운 Annotaion입니다. 그것은 소비를 지원합니다
소비 옵션은 다음과 같습니다.
소비 = "text / plain"
소비 = { "text / plain", "application / *"}
자세한 내용은 GetMapping Annotation을 참조하십시오.
또는 읽기 : 요청 매핑 변형
RequestMapping은 소비도 지원합니다
당신이 볼 수 있듯이 여기 :
특히,
@GetMapping
에 대한 바로 가기 역할을하는 구성된 주석입니다@RequestMapping(method = RequestMethod.GET)
.
@GetMapping
&의 차이점@RequestMapping
@GetMapping
consumes
와 같은 속성을 지원합니다@RequestMapping
.
@RequestMapping
수업 수준입니다
@GetMapping
방법 수준입니다
스프린트 봄 4.3. 그리고 위로 물건이 바뀌었다. 이제 http 요청을 처리 할 메소드에서 @GetMapping을 사용할 수 있습니다. 클래스 레벨 @RequestMapping 스펙은 (메소드 레벨) @GetMapping 주석으로 세분화됩니다.
예를 들면 다음과 같습니다.
@Slf4j
@Controller
@RequestMapping("/orders")/* The @Request-Mapping annotation, when applied
at the class level, specifies the kind of requests
that this controller handles*/
public class OrderController {
@GetMapping("/current")/*@GetMapping paired with the classlevel
@RequestMapping, specifies that when an
HTTP GET request is received for /order,
orderForm() will be called to handle the request..*/
public String orderForm(Model model) {
model.addAttribute("order", new Order());
return "orderForm";
}
}
Spring 4.3 이전에는 @RequestMapping(method=RequestMethod.GET)
짧은 답변:
시맨틱에는 차이가 없습니다.
특히 @GetMapping은 @RequestMapping (method = RequestMethod.GET) 의 바로 가기 역할을 하는 구성된 주석입니다 .
더 읽을 거리 :
RequestMapping
수업 레벨에서 사용할 수 있습니다 :
This annotation can be used both at the class and at the method level. In most cases, at the method level applications will prefer to use one of the HTTP method specific variants @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, or @PatchMapping.
while GetMapping
only applies to method:
Annotation for mapping HTTP GET requests onto specific handler methods.
'Programing' 카테고리의 다른 글
Django와 ReactJS를 함께 사용하는 방법? (0) | 2020.07.10 |
---|---|
값이 없으면 URL 쿼리 매개 변수가 유효합니까? (0) | 2020.07.10 |
어떤 브랜치와 병합하길 원하는지 알려주지 말고 (0) | 2020.07.10 |
XML 사이트 맵에 어떤 콘텐츠 유형 값을 보내야합니까? (0) | 2020.07.10 |
다른 어셈블리에서 두 개의 부분 클래스를 사용하여 동일한 클래스를 나타낼 수 있습니까? (0) | 2020.07.10 |