File tree 2 files changed +19
-1
lines changed
spring-webmvc/src/main/java/org/springframework/web/servlet/handler 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2021 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.
48
48
import org .springframework .web .cors .CorsUtils ;
49
49
import org .springframework .web .method .HandlerMethod ;
50
50
import org .springframework .web .servlet .HandlerMapping ;
51
+ import org .springframework .web .util .pattern .PathPatternParser ;
51
52
52
53
/**
53
54
* Abstract base class for {@link HandlerMapping} implementations that define
@@ -99,6 +100,14 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
99
100
private final MappingRegistry mappingRegistry = new MappingRegistry ();
100
101
101
102
103
+ @ Override
104
+ public void setPatternParser (PathPatternParser patternParser ) {
105
+ Assert .state (this .mappingRegistry .getRegistrations ().isEmpty (),
106
+ "PathPatternParser must be set before the initialization of " +
107
+ "request mappings through InitializingBean#afterPropertiesSet." );
108
+ super .setPatternParser (patternParser );
109
+ }
110
+
102
111
/**
103
112
* Whether to detect handler methods in beans in ancestor ApplicationContexts.
104
113
* <p>Default is "false": Only beans in the current ApplicationContext are
Original file line number Diff line number Diff line change 41
41
import org .springframework .web .util .ServletRequestPathUtils ;
42
42
import org .springframework .web .util .UrlPathHelper ;
43
43
import org .springframework .web .util .pattern .PathPattern ;
44
+ import org .springframework .web .util .pattern .PathPatternParser ;
44
45
45
46
/**
46
47
* Abstract base class for URL-mapped {@link HandlerMapping} implementations.
@@ -74,6 +75,14 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
74
75
private final Map <PathPattern , Object > pathPatternHandlerMap = new LinkedHashMap <>();
75
76
76
77
78
+ @ Override
79
+ public void setPatternParser (PathPatternParser patternParser ) {
80
+ Assert .state (this .handlerMap .isEmpty (),
81
+ "PathPatternParser must be set before the initialization of " +
82
+ "the handler map via ApplicationContextAware#setApplicationContext." );
83
+ super .setPatternParser (patternParser );
84
+ }
85
+
77
86
/**
78
87
* Set the root handler for this handler mapping, that is,
79
88
* the handler to be registered for the root path ("/").
You can’t perform that action at this time.
0 commit comments