-
Notifications
You must be signed in to change notification settings - Fork 472
ControllerLinkBuilderFactory should resolve placeholders #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Normally, when linking to methods with request mappings having path variables, the variable value should be defined by some method argument. You pass it in after methodOn() when you 'call' the target method. Could you please post how you use linkTo(methodOn())? Btw. the notation with $ is not what I'm used to. Did you mean "/{myPath}/users"? Dietrich Schulten ---- Matthias schrieb ----
|
Spring MVC does resolve the @RequestMapping(value = "${myPath}/users") to a mapping like "/somePath/users" if the PropertyPlaceholderConfigurer resolves ${myPath} to "somePath". ${myPath} is therefor replaced when starting the application. All arguements like you mention {xxx} (PathVariables) must be given in the request. I'm using the ControllerLinkBuilder like: linkTo(methodOn(RestUsersController.class).getAllUsers()).withSelfRel()) |
A solution could be to make |
Sure, this would be a good solution. |
I haven't been able to implement the fix in spring-hateoas directly, since I implemented a temporary fix in my projects by extending |
Resolved via #361. |
The ControllerLinkBuilderFactory does not resolve placeholders in RequestMapping annotations.
Ex. @RequestMapping(value = "${myPath}/users")
The handling should be the same as in the RequestMappingHandlerMapping.
Stacktrace:
java.lang.IllegalArgumentException: Map has no value for 'myPath'
at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:277) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:221) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents$FullPathComponent.expand(HierarchicalUriComponents.java:642) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:311) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:46) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.UriComponents.expand(UriComponents.java:152) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:288) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:145) ~[spring-hateoas-0.15.0.RELEASE.jar:na]
at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:135) ~[spring-hateoas-0.15.0.RELEASE.jar:na]
The text was updated successfully, but these errors were encountered: