Servlet mapping does not match base on SUFFIX style
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [ben.andrea](https://code.google.com/u/112140932805552236028/) on February 08, 2013 13:24:00_
Description of the issue: Steps to reproduce: 1. Bind a servlet to a path with serve("/myservlet/*").with(MyServlet.class) that handles GETs.
2. Send a GET request to the server at the path /myservlet.
3. The bound servlet definition with Guice will not match the path in the request due to the way that the ServletStyleUriPatternMatcher creates its pattern.
A change like this is one possible solution:
public ServletStyleUriPatternMatcher(String pattern) {
if (pattern.startsWith("*")) {
this.pattern = pattern.substring(1);
this.patternKind = Kind.PREFIX;
} else if (pattern.endsWith("/*")) {
this.pattern = pattern.substring(0, pattern.length() - 2);
this.patternKind = Kind.SUFFIX;
} else {
this.pattern = pattern;
this.patternKind = Kind.LITERAL;
}
}
The SUFFIX style will correctly match both '/myservlet' and '/myservlet/something' paths which matches the servlet specification in section SRV.11.2.
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=741_
Contributor guide
Assessment
This issue has not been assessed yet.