我需要在java中进行一些基本的url匹配。我需要将返回true的方法,说用于检查URL是否适合模式的Java方法
/users/5/roles
比赛
/users/*/roles
这里就是我要寻找什么,我试过了。
public Boolean fitsTemplate(String path, String template) {
Boolean matches = false;
//My broken code, since it returns false and I need true
matches = path.matches(template);
return matches;
}
好像你可能想要一个蚂蚁匹配器;有这样的库可用。 – chrylis
'users/5/6/7/roles'应该返回什么? [String.matches()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#matches(java.lang.String))需要一个正则表达式,'/用户/ [0-9] + /角色“应该可以工作。 –
@JohnBupit false – JellyRaptor