Browse Source

Working on SPR-5631 - Implicit /** mapping on type-level @RequestMapping

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1011 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Arjen Poutsma 17 years ago
parent
commit
77d364af60
  1. 16
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/DefaultAnnotationHandlerMapping.java
  2. 20
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

16
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/DefaultAnnotationHandlerMapping.java

@ -110,11 +110,19 @@ public class DefaultAnnotationHandlerMapping extends AbstractDetectingUrlHandler @@ -110,11 +110,19 @@ public class DefaultAnnotationHandlerMapping extends AbstractDetectingUrlHandler
// @RequestMapping found at type level
this.cachedMappings.put(handlerType, mapping);
Set<String> urls = new LinkedHashSet<String>();
String[] paths = mapping.value();
if (paths.length > 0) {
String[] typeLevelPaths = mapping.value();
if (typeLevelPaths.length > 0) {
// @RequestMapping specifies paths at type level
for (String path : paths) {
addUrlsForPath(urls, path);
String[] methodLevelPaths = determineUrlsForHandlerMethods(handlerType);
for (String typeLevelPath : typeLevelPaths) {
if (!typeLevelPath.startsWith("/")) {
typeLevelPath = "/" + typeLevelPath;
}
for (String methodLevelPath : methodLevelPaths) {
String combinedPath = getPathMatcher().combine(typeLevelPath, methodLevelPath);
addUrlsForPath(urls, combinedPath);
}
addUrlsForPath(urls, typeLevelPath);
}
return StringUtils.toStringArray(urls);
}

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

@ -1,3 +1,19 @@ @@ -1,3 +1,19 @@
/*
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.mvc.annotation;
import java.io.IOException;
@ -8,8 +24,8 @@ import javax.servlet.ServletException; @@ -8,8 +24,8 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.RootBeanDefinition;
@ -73,7 +89,6 @@ public class UriTemplateServletAnnotationControllerTests { @@ -73,7 +89,6 @@ public class UriTemplateServletAnnotationControllerTests {
}
@Test
@Ignore("In progress")
public void relative() throws Exception {
initServlet(RelativePathUriTemplateController.class);
@ -120,7 +135,6 @@ public class UriTemplateServletAnnotationControllerTests { @@ -120,7 +135,6 @@ public class UriTemplateServletAnnotationControllerTests {
}
@Test
@Ignore("In progress")
public void implicitSubPath() throws Exception {
initServlet(ImplicitSubPathController.class);

Loading…
Cancel
Save