File tree 2 files changed +12
-1
lines changed
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -61,6 +61,10 @@ public ViewControllerRegistry(@Nullable ApplicationContext applicationContext) {
61
61
* <p>Patterns like {@code "/admin/**"} or {@code "/articles/{articlename:\\w+}"}
62
62
* are allowed. See {@link org.springframework.util.AntPathMatcher} for more details on the
63
63
* syntax.
64
+ * <p><strong>Note:</strong> If an {@code @RequestMapping} method is mapped
65
+ * to a URL for any HTTP method then a view controller cannot handle the
66
+ * same URL. For this reason it is recommended to avoid splitting URL
67
+ * handling across an annotated controller and a view controller.
64
68
*/
65
69
public ViewControllerRegistration addViewController (String urlPath ) {
66
70
ViewControllerRegistration registration = new ViewControllerRegistration (urlPath );
Original file line number Diff line number Diff line change @@ -5399,6 +5399,13 @@ using the `<mvc:view-controller>` element:
5399
5399
<mvc:view-controller path="/" view-name="home"/>
5400
5400
----
5401
5401
5402
+ If an `@RequestMapping` method is mapped to a URL for any HTTP method then a view
5403
+ controller cannot be used to handle the same URL. This is because a match by URL to an
5404
+ annotated controller is considered a strong enough indication of endpoint ownership so
5405
+ that a 405 (METHOD_NOT_ALLOWED), a 415 (UNSUPPORTED_MEDIA_TYPE), or similar response can
5406
+ be sent to the client to help with debugging. For this reason it is recommended to avoid
5407
+ splitting URL handling across an annotated controller and a view controller.
5408
+
5402
5409
5403
5410
5404
5411
[[mvc-config-view-resolvers]]
You can’t perform that action at this time.
0 commit comments