Skip to content

Custom @RequestMapping annotations [SPR-12296] #16901

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sérgio Vale e Pace opened SPR-12296 and commented

Support creating annotations with @RequestMapping meta-annotation like it is possible to do with the @Component annotation.

For instance, I would like to create an annotation @PostJson that would replace a @RequestMapping with parameters:

@RequestMapping(
    method = RequestMethod.POST, 
    produces = MediaType.APPLICATION_JSON_VALUE
    consumes = MediaType.APPLICATION_JSON_VALUE)
public @interface PostJson {
    String value() default "";
}

So I could write:

@PostJson("/input")
public Output myMethod(Input input) {

instead of:

@RequestMapping(value = "/input",
    method = RequestMethod.POST,
    produces = MediaType.APPLICATION_JSON_VALUE, 
    consumes = MediaType.APPLICATION_JSON_VALUE)
public Output myMethod(Input input) {

Affects: 4.1.1

Reference URL: http://stackoverflow.com/questions/26049810/create-annotation-setting-requestmapping-parameters-using-spring-mvc/26050717#26050717

Issue Links:

1 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions