SPR-5726: Unexpected @RequestMapping semantics when class-level and method-level mappings used together

This commit is contained in:
Arjen Poutsma 2009-05-08 10:02:17 +00:00
parent 266a65982d
commit 4025df1ef8
2 changed files with 4 additions and 2 deletions

View File

@ -62,6 +62,7 @@ import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.PathMatcher; import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.support.BindingAwareModelMap; import org.springframework.validation.support.BindingAwareModelMap;
@ -502,7 +503,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator implemen
} }
private boolean isPathMatch(String methodLevelPattern, String lookupPath) { private boolean isPathMatch(String methodLevelPattern, String lookupPath) {
if (isPathMatchInternal(methodLevelPattern, lookupPath)) { if ((!hasTypeLevelMapping() || ObjectUtils.isEmpty(getTypeLevelMapping().value())) &&
isPathMatchInternal(methodLevelPattern, lookupPath)) {
return true; return true;
} }
if (hasTypeLevelMapping()) { if (hasTypeLevelMapping()) {

View File

@ -319,7 +319,7 @@ public class UriTemplateServletAnnotationControllerTests {
writer.write("create"); writer.write("create");
} }
@RequestMapping(value = "{hotel}", method = RequestMethod.GET) @RequestMapping(value = "/{hotel}", method = RequestMethod.GET)
public void show(@PathVariable String hotel, Writer writer) throws IOException { public void show(@PathVariable String hotel, Writer writer) throws IOException {
writer.write("show-" + hotel); writer.write("show-" + hotel);
} }