Introduce common SimpleUrlHandlerMapping constructors
Prior to this commit, the SimpleUrlHandlerMapping classes in Spring MVC
and Spring Webflux only had default constructors. This lead to the fact
that users often had to explicitly invoke setUrlMap() and setOrder() on
the newly instantiated SimpleUrlHandlerMapping.
In order to simplify the programmatic setup of a SimpleUrlHandlerMapping
in common scenarios, this commit introduces the following constructors.
- SimpleUrlHandlerMapping()
- SimpleUrlHandlerMapping(Map<String, ?> urlMap)
- SimpleUrlHandlerMapping(Map<String, ?> urlMap, int order)
Closes gh-23362
@ -56,6 +56,39 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
@@ -56,6 +56,39 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
@ -119,20 +119,16 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
@@ -119,20 +119,16 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
@ -145,12 +145,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
@@ -145,12 +145,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
@ -59,6 +61,39 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
@@ -59,6 +61,39 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
@ -53,11 +53,9 @@ Then you can map it to a URL and add a `WebSocketHandlerAdapter`, as the followi
@@ -53,11 +53,9 @@ Then you can map it to a URL and add a `WebSocketHandlerAdapter`, as the followi
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/path", new MyWebSocketHandler());
int order = -1; // before annotated controllers
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(map);
mapping.setOrder(-1); // before annotated controllers