Skip to content

mvc Parameter annotations are not inherited [SPR-14526] #19095

Closed
@spring-projects-issues

Description

@spring-projects-issues

Terence Mill opened SPR-14526 and commented

 @RequestMapping(method = RequestMethod.GET, value = "/{userId}", produces = "application/json", consumes = "application/json")
public IUser getUserById(@PathVariable("userId") Long userId);

Calling @Get on PROT://DOMAIN/users/1 -> userId is NULL :(

@RequestMapping("/users") public interface IUserEndpoint {..} 
@RestController public class UserEndpoint extends implements IUserEndpoint {..}

(!) It only works if i repeat @PathVariable in my implementing @RestController

@RestController public class UserEndpoint extends implements IUserEndpoint {
public IUser getUserById(@PathVariable("userId") Long userId);

Repeating the REST contract is an ugly workaround


Affects: 4.2.6

Issue Links:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions