0

I have following request mapping.

@RequestMapping(value = "/{userId}", produces = { MediaTypes.HAL_JSON_VALUE })
@ResponseStatus(HttpStatus.OK)
public Resource<UserDTO> findUser(@PathVariable final String userId) {
    User user = administrationService.getSecurityUserById(userId);
    return userResourceAssembler.toResource(modelMapper.map(user, UserDTO.class));
}

I use RestTemplate to get the resource. The user ids passed in the url contain a dot (.) like: john.doe -> request URL: http://mysite/users/john.doe When the above method gets called I only get john in @PathVariable userId.

How can this be fixed? to get john.doe

Thx.

1 Answers1

0

anything that goes after a dot in RequestMapping is considered an extension and therefore ignored, if you want to be able to read along with the dot and the rest of the string I recommend using a regex in your Request mapping such as: /{userId:.+} more detailed explanation can be found here: Spring MVC @PathVariable with dot (.) is getting truncated

Community
  • 1
  • 1
Daniel Arechiga
  • 847
  • 7
  • 19