正则表达式匹配URL中的访问资源 3C

java语言编写,匹配URL中的访问资源,不匹配后面的参数,正则表达式怎么写?
"GET /SchoolClubManage/jsp/common/applyjoinclub.html?name=../../../../../../../../../../etc/passwd%00.jpg HTTP/1.1" 200 5953
这条记录只匹配/SchoolClubManage/jsp/common/applyjoinclub.html?

"GET /SchoolClubManage/font/ HTTP/1.1" 200 3216
这条记录只匹配 /SchoolClubManage/font

多谢,急急急

3个回答

 PathMatcher matcher = new AntPathMatcher()
 String uri = "/user/rest/isc/user/UUID1238weqw123";
 String pattern = "/user/rest/isc/user/**";
 matcher.match(pattern, uri);

可以不用正则,使用这个IndexOf()吗

Pattern p = Pattern.compile("/SchoolClubManage/.*?[\? ]");
Matcher m= p.matcher("GET /SchoolClubManage/jsp/common/applyjoinclub.html?name=../../../../../../../../../../etc/passwd%00.jpg HTTP/1.1\" 200 5953");
if(m.find()){
System.out.println(m.group());
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐