有个url:/result/last/location/{locationId}/*
如何通过 HttpServletRequest 用正则表达式把 {locationId} 中内容获取到
求教!!!!谢谢!!!!!
有个url:/result/last/location/{locationId}/*
如何通过 HttpServletRequest 用正则表达式把 {locationId} 中内容获取到
求教!!!!谢谢!!!!!
String str = "/result/last/location/{locationId}/*";
String regex = "/\\{(\\w+)\\}/\\*";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
while(m.find()){
System.out.println(m.group());
}
不知道这样符不符合你的要求
4 回答1.3k 阅读✓ 已解决
4 回答1.2k 阅读✓ 已解决
1 回答2.5k 阅读✓ 已解决
2 回答710 阅读✓ 已解决
2 回答1.7k 阅读
2 回答1.6k 阅读
2 回答1.3k 阅读
你可以通过 spring的注解@PathVariable来获得locationId
你也可以通过string 的split来截取