Java 中的 RESTful 字符串匹配器 [英] RESTful Strings matcher in Java

查看:70
本文介绍了Java 中的 RESTful 字符串匹配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找评估 REST 样式 URL 的 Java 库.类似的东西:

I'm looking for a Java library that evaluates REST-style URLs. Something like:

public Result evaluate(String url, String pattern);

模式将类似于:

/users/{userId}/photos/{photoId}.html

结果必须包括:

  • 指示 url 是否匹配模式
  • url 变量的实际值 {userId}{photoId}

有人可以帮忙吗?

推荐答案

评估"是指某种统一或模式匹配,其中 url 字符串与 字符串匹配>pattern 字符串,将模式中的占位符映射到 URL 中对应的子字符串?

By "evaluate", do you mean some kind of unification or pattern matching by which the url string is matched against the pattern string, mapping the placeholders in the pattern to the corresponding substrings in the URL?

如果是这样,Restlet 库Template class 可能就足够了.具体看 Template#parse(String, Map).这看起来很接近您的需求,尽管文档对于输入和输出的构成有点模糊.

If so, the Restlet library's Template class may suffice. In particular, look at Template#parse(String, Map<String, Object>). That looks close to fitting your needs, though the documentation is a little vague as to what constitutes the input and output.

这篇关于Java 中的 RESTful 字符串匹配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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