Before upgrading to spring3 and spring6, a URL with multiple slashes, for example //aaa///bb
, can be mapped to controller /aa/bb
, but now I am using Spring Boot 3.1.7 and spring-webmvc
6.0.14 which results in 404 not found.
I debugged and found in this method:
protected String initLookupPath(HttpServletRequest request) {
if (usesPathPatterns()) { //after upgrading will come to this brance because PathPatterParser is set to default
request.removeAttribute(UrlPathHelper.PATH_ATTRIBUTE);
RequestPath requestPath = getRequestPath(request);
String lookupPath = requestPath.pathWithinApplication().value();
return UrlPathHelper.defaultInstance.removeSemicolonContent(lookupPath); //here will return "//aaa///bb" finally no handler will be found
}
else { //before upgrading will come to this branch and will return "/aa/bb"
return getUrlPathHelper().resolveAndCacheLookupPath(request);
}
}
I am not sure if this is a bug or it is me not using it correctly.
BTW i have this config: spring.mvc.pathmatch.matching-strategy=ant_path_matcher
Is there anything I can do to prevent 404?
many thanks
Comment From: sbrannen
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.
Comment From: sdeleuze
@wwwwwwwty Could you please share a reproducer of the problem you see (as an attached archive or a link to a repository) and let us know what was the original version of Spring Boot / Spring Framework you were using before the upgrade?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.