diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java
index 8301ce7c4df..d1c55b7f02e 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2012 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.
@@ -32,8 +32,8 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
/**
- * Creates {@link RequestMappingInfo} instances from type and method-level
- * {@link RequestMapping @RequestMapping} annotations in
+ * Creates {@link RequestMappingInfo} instances from type and method-level
+ * {@link RequestMapping @RequestMapping} annotations in
* {@link Controller @Controller} classes.
*
* @author Arjen Poutsma
@@ -45,16 +45,16 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
private boolean useSuffixPatternMatch = true;
private boolean useTrailingSlashMatch = true;
-
+
/**
* Whether to use suffix pattern match (".*") when matching patterns to
* requests. If enabled a method mapped to "/users" also matches to "/users.*".
- *
The default value is {@code true}.
+ *
The default value is {@code true}.
*/
public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) {
this.useSuffixPatternMatch = useSuffixPatternMatch;
}
-
+
/**
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a method mapped to "/users" also matches to "/users/".
@@ -78,21 +78,22 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
* Expects a handler to have a type-level @{@link Controller} annotation.
*/
@Override
protected boolean isHandler(Class> beanType) {
- return AnnotationUtils.findAnnotation(beanType, Controller.class) != null;
+ return ((AnnotationUtils.findAnnotation(beanType, Controller.class) != null) ||
+ (AnnotationUtils.findAnnotation(beanType, RequestMapping.class) != null));
}
/**
* Uses method and type-level @{@link RequestMapping} annotations to create
* the RequestMappingInfo.
- *
+ *
* @return the created RequestMappingInfo, or {@code null} if the method
* does not have a {@code @RequestMapping} annotation.
- *
+ *
* @see #getCustomMethodCondition(Method)
* @see #getCustomTypeCondition(Class)
*/
@@ -114,22 +115,22 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
/**
* Provide a custom method-level request condition.
- * The custom {@link RequestCondition} can be of any type so long as the
+ * The custom {@link RequestCondition} can be of any type so long as the
* same condition type is returned from all calls to this method in order
- * to ensure custom request conditions can be combined and compared.
+ * to ensure custom request conditions can be combined and compared.
* @param method the handler method for which to create the condition
* @return the condition, or {@code null}
*/
protected RequestCondition> getCustomMethodCondition(Method method) {
return null;
}
-
+
/**
* Provide a custom type-level request condition.
- * The custom {@link RequestCondition} can be of any type so long as the
+ * The custom {@link RequestCondition} can be of any type so long as the
* same condition type is returned from all calls to this method in order
- * to ensure custom request conditions can be combined and compared.
- * @param method the handler method for which to create the condition
+ * to ensure custom request conditions can be combined and compared.
+ * @param handlerType the handler type for which to create the condition
* @return the condition, or {@code null}
*/
protected RequestCondition> getCustomTypeCondition(Class> handlerType) {
@@ -141,13 +142,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
*/
private RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition> customCondition) {
return new RequestMappingInfo(
- new PatternsRequestCondition(annotation.value(),
+ new PatternsRequestCondition(annotation.value(),
getUrlPathHelper(), getPathMatcher(), this.useSuffixPatternMatch, this.useTrailingSlashMatch),
new RequestMethodsRequestCondition(annotation.method()),
new ParamsRequestCondition(annotation.params()),
new HeadersRequestCondition(annotation.headers()),
new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
- new ProducesRequestCondition(annotation.produces(), annotation.headers()),
+ new ProducesRequestCondition(annotation.produces(), annotation.headers()),
customCondition);
}
diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
index e624933bdd8..3816f4b5de8 100644
--- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
+++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
@@ -51,37 +51,37 @@ import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.ModelAndView;
/**
- * Test various scenarios for detecting method-level and method parameter annotations depending
- * on where they are located -- on interfaces, parent classes, in parameterized methods, or in
+ * Test various scenarios for detecting method-level and method parameter annotations depending
+ * on where they are located -- on interfaces, parent classes, in parameterized methods, or in
* combination with proxies.
- *
+ *
* @author Rossen Stoyanchev
*/
@RunWith(Parameterized.class)
public class HandlerMethodAnnotationDetectionTests {
-
+
@Parameters
public static Collection