-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Sam Brannen opened SPR-13441 and commented
Status Quo
Although Spring MVC supports @RequestMapping as a merged annotation, the same is not true for @ResponseStatus. @ResponseStatus is in fact supported as a meta-annotation, just not as a merged annotation. This means that the responseStatus attribute override in the following custom composed @Post annotation is currently unsupported even though it is declared syntactically correct. Furthermore, use of the responseStatus attribute will fail silently: it will simply be ignored.
@RequestMapping(method = POST)
@ResponseStatus
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Post {
@AliasFor(annotation = RequestMapping.class, attribute = "path")
String[] value() default {};
@AliasFor(annotation = RequestMapping.class, attribute = "path")
String[] path() default {};
@AliasFor(annotation = ResponseStatus.class, attribute = "code")
HttpStatus responseStatus() default HttpStatus.CREATED;
}Deliverables
- Look up
@ResponseStatususingAnnotatedElementUtils.findMergedAnnotation()instead ofAnnotationUtils.findAnnotation().
Affects: 4.2 GA
Issue Links:
- Provide a mechanism for composed annotations to signal that they want to override attributes [SPR-13448] #18028 Provide a mechanism for composed annotations to signal that they want to override attributes
- Use AnnotatedElementUtils instead of AnnotationUtils wherever feasible [SPR-13440] #18020 Use AnnotatedElementUtils instead of AnnotationUtils wherever feasible
- Introduce predefined composed annotations in core Spring [SPR-13442] #18022 Introduce predefined composed annotations in core Spring
- Support @CrossOrigin as a merged composed annotation [SPR-13468] #18047 Support
@CrossOriginas a merged composed annotation - Support @Cache* as merged composed annotations [SPR-13475] #18054 Support
@Cache* as merged composed annotations
Referenced from: commits e2bfbdc
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement