107
107
* subclass and {@link Bean @Bean} to overridden {@link Bean @Bean} methods.
108
108
* For more details see the javadoc of {@link EnableWebMvc @EnableWebMvc}.
109
109
*
110
- * <p>This class registers the following {@link HandlerMapping}s :</p>
110
+ * <p>This class registers the following {@link HandlerMapping HandlerMappings} :</p>
111
111
* <ul>
112
112
* <li>{@link RequestMappingHandlerMapping}
113
113
* ordered at 0 for mapping requests to annotated controller methods.
121
121
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet.
122
122
* </ul>
123
123
*
124
- * <p>Registers these {@link HandlerAdapter}s :
124
+ * <p>Registers these {@link HandlerAdapter HandlerAdapters} :
125
125
* <ul>
126
126
* <li>{@link RequestMappingHandlerAdapter}
127
127
* for processing requests with annotated controller methods.
128
128
* <li>{@link HttpRequestHandlerAdapter}
129
- * for processing requests with {@link HttpRequestHandler}s .
129
+ * for processing requests with {@link HttpRequestHandler HttpRequestHandlers} .
130
130
* <li>{@link SimpleControllerHandlerAdapter}
131
- * for processing requests with interface-based {@link Controller}s .
131
+ * for processing requests with interface-based {@link Controller Controllers} .
132
132
* </ul>
133
133
*
134
134
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of
159
159
* <li>a {@link DefaultFormattingConversionService}
160
160
* <li>a {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}
161
161
* if a JSR-303 implementation is available on the classpath
162
- * <li>a range of {@link HttpMessageConverter}s depending on the third-party
162
+ * <li>a range of {@link HttpMessageConverter HttpMessageConverters} depending on the third-party
163
163
* libraries available on the classpath.
164
164
* </ul>
165
165
*
172
172
*/
173
173
public class WebMvcConfigurationSupport implements ApplicationContextAware , ServletContextAware {
174
174
175
- private static boolean romePresent =
175
+ private static final boolean romePresent =
176
176
ClassUtils .isPresent ("com.rometools.rome.feed.WireFeed" ,
177
177
WebMvcConfigurationSupport .class .getClassLoader ());
178
178
@@ -284,15 +284,16 @@ public RequestMappingHandlerMapping requestMappingHandlerMapping() {
284
284
mapping .setCorsConfigurations (getCorsConfigurations ());
285
285
286
286
PathMatchConfigurer configurer = getPathMatchConfigurer ();
287
+
287
288
Boolean useSuffixPatternMatch = configurer .isUseSuffixPatternMatch ();
288
- Boolean useRegisteredSuffixPatternMatch = configurer .isUseRegisteredSuffixPatternMatch ();
289
- Boolean useTrailingSlashMatch = configurer .isUseTrailingSlashMatch ();
290
289
if (useSuffixPatternMatch != null ) {
291
290
mapping .setUseSuffixPatternMatch (useSuffixPatternMatch );
292
291
}
292
+ Boolean useRegisteredSuffixPatternMatch = configurer .isUseRegisteredSuffixPatternMatch ();
293
293
if (useRegisteredSuffixPatternMatch != null ) {
294
294
mapping .setUseRegisteredSuffixPatternMatch (useRegisteredSuffixPatternMatch );
295
295
}
296
+ Boolean useTrailingSlashMatch = configurer .isUseTrailingSlashMatch ();
296
297
if (useTrailingSlashMatch != null ) {
297
298
mapping .setUseTrailingSlashMatch (useTrailingSlashMatch );
298
299
}
@@ -301,7 +302,6 @@ public RequestMappingHandlerMapping requestMappingHandlerMapping() {
301
302
if (pathHelper != null ) {
302
303
mapping .setUrlPathHelper (pathHelper );
303
304
}
304
-
305
305
PathMatcher pathMatcher = configurer .getPathMatcher ();
306
306
if (pathMatcher != null ) {
307
307
mapping .setPathMatcher (pathMatcher );
@@ -321,8 +321,8 @@ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
321
321
322
322
/**
323
323
* Provide access to the shared handler interceptors used to configure
324
- * {@link HandlerMapping} instances with. This method cannot be overridden,
325
- * use {@link #addInterceptors(InterceptorRegistry) } instead.
324
+ * {@link HandlerMapping} instances with.
325
+ * <p>This method cannot be overridden; use {@link #addInterceptors} instead.
326
326
*/
327
327
protected final Object [] getInterceptors () {
328
328
if (this .interceptors == null ) {
@@ -358,15 +358,15 @@ protected PathMatchConfigurer getPathMatchConfigurer() {
358
358
359
359
/**
360
360
* Override this method to configure path matching options.
361
- * @see PathMatchConfigurer
362
361
* @since 4.0.3
362
+ * @see PathMatchConfigurer
363
363
*/
364
364
protected void configurePathMatch (PathMatchConfigurer configurer ) {
365
365
}
366
366
367
367
/**
368
368
* Return a global {@link PathMatcher} instance for path matching
369
- * patterns in {@link HandlerMapping}s .
369
+ * patterns in {@link HandlerMapping HandlerMappings} .
370
370
* This instance can be configured using the {@link PathMatchConfigurer}
371
371
* in {@link #configurePathMatch(PathMatchConfigurer)}.
372
372
* @since 4.1
@@ -379,7 +379,7 @@ public PathMatcher mvcPathMatcher() {
379
379
380
380
/**
381
381
* Return a global {@link UrlPathHelper} instance for path matching
382
- * patterns in {@link HandlerMapping}s .
382
+ * patterns in {@link HandlerMapping HandlerMappings} .
383
383
* This instance can be configured using the {@link PathMatchConfigurer}
384
384
* in {@link #configurePathMatch(PathMatchConfigurer)}.
385
385
* @since 4.1
@@ -682,9 +682,8 @@ protected Validator getValidator() {
682
682
683
683
/**
684
684
* Provide access to the shared custom argument resolvers used by the
685
- * {@link RequestMappingHandlerAdapter} and the
686
- * {@link ExceptionHandlerExceptionResolver}. This method cannot be
687
- * overridden, use {@link #addArgumentResolvers(List)} instead.
685
+ * {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
686
+ * <p>This method cannot be overridden; use {@link #addArgumentResolvers} instead.
688
687
* @since 4.3
689
688
*/
690
689
protected final List <HandlerMethodArgumentResolver > getArgumentResolvers () {
@@ -696,24 +695,21 @@ protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() {
696
695
}
697
696
698
697
/**
699
- * Add custom {@link HandlerMethodArgumentResolver}s to use in addition to
700
- * the ones registered by default.
701
- * <p>Custom argument resolvers are invoked before built-in resolvers
702
- * except for those that rely on the presence of annotations (e.g.
703
- * {@code @RequestParameter}, {@code @PathVariable}, etc.).
704
- * The latter can be customized by configuring the
698
+ * Add custom {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}
699
+ * to use in addition to the ones registered by default.
700
+ * <p>Custom argument resolvers are invoked before built-in resolvers except for
701
+ * those that rely on the presence of annotations (e.g. {@code @RequestParameter},
702
+ * {@code @PathVariable}, etc). The latter can be customized by configuring the
705
703
* {@link RequestMappingHandlerAdapter} directly.
706
- * @param argumentResolvers the list of custom converters;
707
- * initially an empty list.
704
+ * @param argumentResolvers the list of custom converters (initially an empty list)
708
705
*/
709
706
protected void addArgumentResolvers (List <HandlerMethodArgumentResolver > argumentResolvers ) {
710
707
}
711
708
712
709
/**
713
710
* Provide access to the shared return value handlers used by the
714
- * {@link RequestMappingHandlerAdapter} and the
715
- * {@link ExceptionHandlerExceptionResolver}. This method cannot be
716
- * overridden, use {@link #addReturnValueHandlers(List)} instead.
711
+ * {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
712
+ * <p>This method cannot be overridden; use {@link #addReturnValueHandlers} instead.
717
713
* @since 4.3
718
714
*/
719
715
protected final List <HandlerMethodReturnValueHandler > getReturnValueHandlers () {
@@ -725,27 +721,23 @@ protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() {
725
721
}
726
722
727
723
/**
728
- * Add custom {@link HandlerMethodReturnValueHandler}s in addition to the
729
- * ones registered by default.
730
- * <p>Custom return value handlers are invoked before built-in ones except
731
- * for those that rely on the presence of annotations (e.g.
732
- * {@code @ResponseBody}, {@code @ModelAttribute}, etc.).
733
- * The latter can be customized by configuring the
724
+ * Add custom {@link HandlerMethodReturnValueHandler HandlerMethodReturnValueHandlers}
725
+ * in addition to the ones registered by default.
726
+ * <p>Custom return value handlers are invoked before built-in ones except for
727
+ * those that rely on the presence of annotations (e.g. {@code @ResponseBody},
728
+ * {@code @ModelAttribute}, etc). The latter can be customized by configuring the
734
729
* {@link RequestMappingHandlerAdapter} directly.
735
- * @param returnValueHandlers the list of custom handlers;
736
- * initially an empty list.
730
+ * @param returnValueHandlers the list of custom handlers (initially an empty list)
737
731
*/
738
732
protected void addReturnValueHandlers (List <HandlerMethodReturnValueHandler > returnValueHandlers ) {
739
733
}
740
734
741
735
/**
742
- * Provides access to the shared {@link HttpMessageConverter}s used by the
743
- * {@link RequestMappingHandlerAdapter} and the
736
+ * Provides access to the shared {@link HttpMessageConverter HttpMessageConverters}
737
+ * used by the {@link RequestMappingHandlerAdapter} and the
744
738
* {@link ExceptionHandlerExceptionResolver}.
745
- * This method cannot be overridden.
746
- * Use {@link #configureMessageConverters(List)} instead.
747
- * Also see {@link #addDefaultHttpMessageConverters(List)} that can be
748
- * used to add default message converters.
739
+ * <p>This method cannot be overridden; use {@link #configureMessageConverters} instead.
740
+ * Also see {@link #addDefaultHttpMessageConverters} for adding default message converters.
749
741
*/
750
742
protected final List <HttpMessageConverter <?>> getMessageConverters () {
751
743
if (this .messageConverters == null ) {
@@ -760,32 +752,30 @@ protected final List<HttpMessageConverter<?>> getMessageConverters() {
760
752
}
761
753
762
754
/**
763
- * Override this method to add custom {@link HttpMessageConverter}s to use
764
- * with the {@link RequestMappingHandlerAdapter} and the
765
- * {@link ExceptionHandlerExceptionResolver}. Adding converters to the
766
- * list turns off the default converters that would otherwise be registered
767
- * by default. Also see {@link #addDefaultHttpMessageConverters(List)} that
768
- * can be used to add default message converters.
769
- * @param converters a list to add message converters to;
770
- * initially an empty list.
755
+ * Override this method to add custom {@link HttpMessageConverter HttpMessageConverters}
756
+ * to use with the {@link RequestMappingHandlerAdapter} and the
757
+ * {@link ExceptionHandlerExceptionResolver}.
758
+ * <p>Adding converters to the list turns off the default converters that would
759
+ * otherwise be registered by default. Also see {@link #addDefaultHttpMessageConverters}
760
+ * for adding default message converters.
761
+ * @param converters a list to add message converters to (initially an empty list)
771
762
*/
772
763
protected void configureMessageConverters (List <HttpMessageConverter <?>> converters ) {
773
764
}
774
765
775
766
/**
776
- * Override this method to extend or modify the list of converters after it
777
- * has been configured. This may be useful for example to allow default
778
- * converters to be registered and then insert a custom converter through
779
- * this method.
780
- * @param converters the list of configured converters to extend.
767
+ * Override this method to extend or modify the list of converters after it has
768
+ * been configured. This may be useful for example to allow default converters
769
+ * to be registered and then insert a custom converter through this method.
770
+ * @param converters the list of configured converters to extend
781
771
* @since 4.1.3
782
772
*/
783
773
protected void extendMessageConverters (List <HttpMessageConverter <?>> converters ) {
784
774
}
785
775
786
776
/**
787
777
* Adds a set of default HttpMessageConverter instances to the given list.
788
- * Subclasses can call this method from {@link #configureMessageConverters(List) }.
778
+ * Subclasses can call this method from {@link #configureMessageConverters}.
789
779
* @param messageConverters the list to add the default message converters to
790
780
*/
791
781
protected final void addDefaultHttpMessageConverters (List <HttpMessageConverter <?>> messageConverters ) {
@@ -875,14 +865,12 @@ public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() {
875
865
}
876
866
877
867
/**
878
- * Returns a {@link HandlerExceptionResolverComposite} containing a list
879
- * of exception resolvers obtained either through
880
- * {@link #configureHandlerExceptionResolvers(List)} or through
881
- * {@link #addDefaultHandlerExceptionResolvers(List)}.
882
- * <p><strong>Note:</strong> This method cannot be made final due to CGLib
883
- * constraints. Rather than overriding it, consider overriding
884
- * {@link #configureHandlerExceptionResolvers(List)}, which allows
885
- * providing a list of resolvers.
868
+ * Returns a {@link HandlerExceptionResolverComposite} containing a list of exception
869
+ * resolvers obtained either through {@link #configureHandlerExceptionResolvers} or
870
+ * through {@link #addDefaultHandlerExceptionResolvers}.
871
+ * <p><strong>Note:</strong> This method cannot be made final due to CGLIB constraints.
872
+ * Rather than overriding it, consider overriding {@link #configureHandlerExceptionResolvers}
873
+ * which allows for providing a list of resolvers.
886
874
*/
887
875
@ Bean
888
876
public HandlerExceptionResolver handlerExceptionResolver () {
@@ -900,29 +888,29 @@ public HandlerExceptionResolver handlerExceptionResolver() {
900
888
901
889
/**
902
890
* Override this method to configure the list of
903
- * {@link HandlerExceptionResolver}s to use. Adding resolvers to the list
904
- * turns off the default resolvers that would otherwise be registered by
905
- * default. Also see {@link #addDefaultHandlerExceptionResolvers(List) }
891
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers} to use.
892
+ * <p>Adding resolvers to the list turns off the default resolvers that would otherwise
893
+ * be registered by default. Also see {@link #addDefaultHandlerExceptionResolvers}
906
894
* that can be used to add the default exception resolvers.
907
- * @param exceptionResolvers a list to add exception resolvers to;
908
- * initially an empty list.
895
+ * @param exceptionResolvers a list to add exception resolvers to (initially an empty list)
909
896
*/
910
897
protected void configureHandlerExceptionResolvers (List <HandlerExceptionResolver > exceptionResolvers ) {
911
898
}
912
899
913
900
/**
914
901
* Override this method to extend or modify the list of
915
- * {@link HandlerExceptionResolver}s after it has been configured. This may
916
- * be useful for example to allow default resolvers to be registered and then
917
- * insert a custom one through this method.
902
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers} after it has been configured.
903
+ * <p>This may be useful for example to allow default resolvers to be registered
904
+ * and then insert a custom one through this method.
918
905
* @param exceptionResolvers the list of configured resolvers to extend.
919
906
* @since 4.3
920
907
*/
921
908
protected void extendHandlerExceptionResolvers (List <HandlerExceptionResolver > exceptionResolvers ) {
922
909
}
923
910
924
911
/**
925
- * A method available to subclasses for adding default {@link HandlerExceptionResolver}s.
912
+ * A method available to subclasses for adding default
913
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers}.
926
914
* <p>Adds the following exception resolvers:
927
915
* <ul>
928
916
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through
@@ -1031,7 +1019,8 @@ protected final Map<String, CorsConfiguration> getCorsConfigurations() {
1031
1019
protected void addCorsMappings (CorsRegistry registry ) {
1032
1020
}
1033
1021
1034
- @ Bean @ Lazy
1022
+ @ Bean
1023
+ @ Lazy
1035
1024
public HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
1036
1025
return new HandlerMappingIntrospector ();
1037
1026
}
0 commit comments