Browse Source

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

conversation
Arjen Poutsma 16 years ago
parent
commit
4025df1ef8
  1. 4
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
  2. 2
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

4
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java

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

2
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

@ -319,7 +319,7 @@ public class UriTemplateServletAnnotationControllerTests { @@ -319,7 +319,7 @@ public class UriTemplateServletAnnotationControllerTests {
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 {
writer.write("show-" + hotel);
}

Loading…
Cancel
Save