- Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
I'm using Spring Framework 5.3.4 with Spring Boot 2.4.3.
I have a controller declared in this way:
@Controller @RequestMapping("${saml.sp.controller-base-mapping}") public class ServiceProviderController { /... }So, the property saml.sp.controller-base-mapping is externalized in application.properties file: if its value is sp, this should be equivalent to: @RequestMapping("sp"). And indeed Spring Web MVC handles this well.
However, if I then use MvcUriComponentsBuilder to retrieve the corresponding URL:
MvcUriComponentsBuilder.fromController(ServiceProviderController.class).build().toURL();This returns a UriComponents of: http://localhost:8081/${saml.sp.controller-base-mapping}
First problem: I would have expected the externalized property to be already resolved (so to get http://localhost:8081/sp), because this should be an expansion mechanism that comes BEFORE path variable expansion.
Indeed (and here comes the second problem), if I try to do:
MvcUriComponentsBuilder.fromController(ServiceProviderController.class).buildAndExpand("sp");I then get a UriComponents of: http://localhost:8081/$sp
This is somewhat expected, since path variable expansion is another story and does not use the "$" marker.