Reusing Spring RequestMapping parsing functionality

南笙酒味 提交于 2019-12-11 18:38:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!