Skip to content

Cannot convert PathVariable Map<String,String> when building link #605

@nealeu

Description

@nealeu

In building some infrastructure, we want to use a Map for the path variables

public List<Resource> list(@PathVariable Map<String, String> pathVariables) { ... }

However when we want to build a list using a map:

methodOn(TheController.class).list(mapOfPathVariables)

We get:

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [@org.springframework.web.bind.annotation.PathVariable java.util.Map<java.lang.String, java.lang.String>] to type [java.lang.String]
	at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:206) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
	at org.springframework.hateoas.mvc.AnnotatedParametersParameterAccessor$BoundMethodParameter.asString(AnnotatedParametersParameterAccessor.java:192) ~[spring-hateoas-0.23.0.RELEASE.jar:na]
	at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:150) ~[spring-hateoas-0.23.0.RELEASE.jar:na]
	at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:193) ~[spring-hateoas-0.23.0.RELEASE.jar:na]

Looking at exiting PRs, it seems that a similar issue for property placeholders is in progress on @gregturn's PR #602

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions