问题
I have some properties like /my/{custom}/url
I would need to replace {custom} with some value at runtime
I know that Spring is using "@RequestMapping" with a similar syntax for @PathAttribute matching.
I'm wondering if there is some Class I can reuse from Spring to achieve what I need.
回答1:
A good option for this is to use a UriComponentsBuilder - see reference here: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html
UriComponentsBuilder.fromPath("/test/{one}/{two}").buildAndExpand(map).toUriString()
来源:https://stackoverflow.com/questions/25137307/reusing-spring-requestmapping-parsing-functionality