您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

执行请求时,如何获取在控制器层配置的当前请求映射URL?

执行请求时,如何获取在控制器层配置的当前请求映射URL?

我可以使用以下代码解决此问题。AntPathMatcher是识别属性文件中配置的传入请求和URL是否完全匹配的完美方法。该解决方案对我来说很有用。

AntPathMatcher springMatcher = new AntPathMatcher();
Optional<String> antMatch = props.getMapping().stream()
     .filter(//Perform Some Filter as per need)
    .map(Mapping::getVersion)
    .findFirst();
return antMatch.isPresent() ? antMatch.get() : null;
其他 2022/1/1 18:14:36 有451人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶