【问题标题】:Reusing Spring RequestMapping parsing functionality重用 Spring RequestMapping 解析功能
【发布时间】:2014-08-05 11:06:57
【问题描述】:

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

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

我知道 Spring 使用“@RequestMapping”,其语法与 @PathAttribute 匹配类似。

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

【问题讨论】:

  • 你想要什么样的课?类似于什么? \@RequestMapping 与 \@PathVariable 就足够了。

标签: spring spring-mvc urlparse


【解决方案1】:

一个不错的选择是使用 UriComponentsBuilder - 请参阅此处的参考:http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html

UriComponentsBuilder.fromPath("/test/{one}/{two}").buildAndExpand(map).toUriString()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-08
    • 2012-03-29
    • 1970-01-01
    • 1970-01-01
    • 2014-07-11
    • 2017-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多