重用Spring RequestMapping解析功能 [英] Reusing Spring RequestMapping parsing functionality

查看:143
本文介绍了重用Spring RequestMapping解析功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些属性,例如 /my/{custom}/url

I have some properties like /my/{custom}/url

我需要在运行时将{custom}替换为一些值

I would need to replace {custom} with some value at runtime

我知道Spring正在使用具有类似语法的"@RequestMapping"来实现@PathAttribute匹配.

I know that Spring is using "@RequestMapping" with a similar syntax for @PathAttribute matching.

我想知道是否有一些我可以从Spring重用的类来实现我所需要的.

I'm wondering if there is some Class I can reuse from Spring to achieve what I need.

推荐答案

一个好的选择是使用UriComponentsBuilder-请参见此处的参考:

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()

这篇关于重用Spring RequestMapping解析功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆