Skip to content

linkTo(methodOn(...)) sometimes misses slashes #269

@pcornelissen

Description

@pcornelissen

I regulary use requestmapping that is partly defined on the class and on the method. This is an example:

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    BackofficeUserRepository repository;

    @RequestMapping(value = "{id}", method = RequestMethod.GET)
    public Resource<BackofficeUser> getUser(@PathVariable("id") UUID id) {
        Resource<BackofficeUser> resource = new Resource<>(repository.findUser(id));
        resource.add(linkTo(methodOn(UserController.class).getUser(id)).withSelfRel());
        return resource;
    }
}

This is perfectly legal spring mvc and it adds the missing slash between "user" and "{id}". But when I use the linkbuilder it doesn't do that. The result of the code above is a link like "http://localhost/user105a8719-8d59-422d-84ba-cf53b9c93447".

As a workaround I can add the slash in my mapping, but I think the linkbuilder should come to the same conclusion as spring mvc when it comes to generating the links based in requestmapping annotations. ;-)

I'm using the version 0.16 BTW.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions