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
This commit is contained in:
@@ -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
|
||||
return mapping;
|
||||
return new SimpleUrlHandlerMapping(map, order);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user