105
105
* subclass and {@link Bean @Bean} to overridden {@link Bean @Bean} methods.
106
106
* For more details see the javadoc of {@link EnableWebMvc @EnableWebMvc}.
107
107
*
108
- * <p>This class registers the following {@link HandlerMapping}s :</p>
108
+ * <p>This class registers the following {@link HandlerMapping HandlerMappings} :</p>
109
109
* <ul>
110
110
* <li>{@link RequestMappingHandlerMapping}
111
111
* ordered at 0 for mapping requests to annotated controller methods.
119
119
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet.
120
120
* </ul>
121
121
*
122
- * <p>Registers these {@link HandlerAdapter}s :
122
+ * <p>Registers these {@link HandlerAdapter HandlerAdapters} :
123
123
* <ul>
124
124
* <li>{@link RequestMappingHandlerAdapter}
125
125
* for processing requests with annotated controller methods.
126
126
* <li>{@link HttpRequestHandlerAdapter}
127
- * for processing requests with {@link HttpRequestHandler}s .
127
+ * for processing requests with {@link HttpRequestHandler HttpRequestHandlers} .
128
128
* <li>{@link SimpleControllerHandlerAdapter}
129
- * for processing requests with interface-based {@link Controller}s .
129
+ * for processing requests with interface-based {@link Controller Controllers} .
130
130
* </ul>
131
131
*
132
132
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of
157
157
* <li>a {@link DefaultFormattingConversionService}
158
158
* <li>a {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}
159
159
* if a JSR-303 implementation is available on the classpath
160
- * <li>a range of {@link HttpMessageConverter}s depending on the third-party
160
+ * <li>a range of {@link HttpMessageConverter HttpMessageConverters} depending on the third-party
161
161
* libraries available on the classpath.
162
162
* </ul>
163
163
*
171
171
*/
172
172
public class WebMvcConfigurationSupport implements ApplicationContextAware , ServletContextAware {
173
173
174
- private static boolean romePresent =
174
+ private static final boolean romePresent =
175
175
ClassUtils .isPresent ("com.rometools.rome.feed.WireFeed" ,
176
176
WebMvcConfigurationSupport .class .getClassLoader ());
177
177
@@ -260,15 +260,20 @@ public RequestMappingHandlerMapping requestMappingHandlerMapping() {
260
260
mapping .setCorsConfigurations (getCorsConfigurations ());
261
261
262
262
PathMatchConfigurer configurer = getPathMatchConfigurer ();
263
- if (configurer .isUseSuffixPatternMatch () != null ) {
264
- mapping .setUseSuffixPatternMatch (configurer .isUseSuffixPatternMatch ());
263
+
264
+ Boolean useSuffixPatternMatch = configurer .isUseSuffixPatternMatch ();
265
+ if (useSuffixPatternMatch != null ) {
266
+ mapping .setUseSuffixPatternMatch (useSuffixPatternMatch );
265
267
}
266
- if (configurer .isUseRegisteredSuffixPatternMatch () != null ) {
267
- mapping .setUseRegisteredSuffixPatternMatch (configurer .isUseRegisteredSuffixPatternMatch ());
268
+ Boolean useRegisteredSuffixPatternMatch = configurer .isUseRegisteredSuffixPatternMatch ();
269
+ if (useRegisteredSuffixPatternMatch != null ) {
270
+ mapping .setUseRegisteredSuffixPatternMatch (useRegisteredSuffixPatternMatch );
268
271
}
269
- if (configurer .isUseTrailingSlashMatch () != null ) {
270
- mapping .setUseTrailingSlashMatch (configurer .isUseTrailingSlashMatch ());
272
+ Boolean useTrailingSlashMatch = configurer .isUseTrailingSlashMatch ();
273
+ if (useTrailingSlashMatch != null ) {
274
+ mapping .setUseTrailingSlashMatch (useTrailingSlashMatch );
271
275
}
276
+
272
277
UrlPathHelper pathHelper = configurer .getUrlPathHelper ();
273
278
if (pathHelper != null ) {
274
279
mapping .setUrlPathHelper (pathHelper );
@@ -292,8 +297,8 @@ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
292
297
293
298
/**
294
299
* Provide access to the shared handler interceptors used to configure
295
- * {@link HandlerMapping} instances with. This method cannot be overridden,
296
- * use {@link #addInterceptors(InterceptorRegistry) } instead.
300
+ * {@link HandlerMapping} instances with.
301
+ * <p>This method cannot be overridden; use {@link #addInterceptors} instead.
297
302
*/
298
303
protected final Object [] getInterceptors () {
299
304
if (this .interceptors == null ) {
@@ -329,15 +334,15 @@ protected PathMatchConfigurer getPathMatchConfigurer() {
329
334
330
335
/**
331
336
* Override this method to configure path matching options.
332
- * @see PathMatchConfigurer
333
337
* @since 4.0.3
338
+ * @see PathMatchConfigurer
334
339
*/
335
340
protected void configurePathMatch (PathMatchConfigurer configurer ) {
336
341
}
337
342
338
343
/**
339
344
* Return a global {@link PathMatcher} instance for path matching
340
- * patterns in {@link HandlerMapping}s .
345
+ * patterns in {@link HandlerMapping HandlerMappings} .
341
346
* This instance can be configured using the {@link PathMatchConfigurer}
342
347
* in {@link #configurePathMatch(PathMatchConfigurer)}.
343
348
* @since 4.1
@@ -350,7 +355,7 @@ public PathMatcher mvcPathMatcher() {
350
355
351
356
/**
352
357
* Return a global {@link UrlPathHelper} instance for path matching
353
- * patterns in {@link HandlerMapping}s .
358
+ * patterns in {@link HandlerMapping HandlerMappings} .
354
359
* This instance can be configured using the {@link PathMatchConfigurer}
355
360
* in {@link #configurePathMatch(PathMatchConfigurer)}.
356
361
* @since 4.1
@@ -586,9 +591,8 @@ protected void configureAsyncSupport(AsyncSupportConfigurer configurer) {
586
591
}
587
592
588
593
/**
589
- * Return a {@link FormattingConversionService} for use with annotated
590
- * controller methods and the {@code spring:eval} JSP tag.
591
- * Also see {@link #addFormatters} as an alternative to overriding this method.
594
+ * Return a {@link FormattingConversionService} for use with annotated controllers.
595
+ * <p>See {@link #addFormatters} as an alternative to overriding this method.
592
596
*/
593
597
@ Bean
594
598
public FormattingConversionService mvcConversionService () {
@@ -598,7 +602,9 @@ public FormattingConversionService mvcConversionService() {
598
602
}
599
603
600
604
/**
601
- * Override this method to add custom {@link Converter}s and {@link Formatter}s.
605
+ * Override this method to add custom {@link Converter} and/or {@link Formatter}
606
+ * delegates to the common {@link FormattingConversionService}.
607
+ * @see #mvcConversionService()
602
608
*/
603
609
protected void addFormatters (FormatterRegistry registry ) {
604
610
}
@@ -645,9 +651,8 @@ protected Validator getValidator() {
645
651
646
652
/**
647
653
* Provide access to the shared custom argument resolvers used by the
648
- * {@link RequestMappingHandlerAdapter} and the
649
- * {@link ExceptionHandlerExceptionResolver}. This method cannot be
650
- * overridden, use {@link #addArgumentResolvers(List)} instead.
654
+ * {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
655
+ * <p>This method cannot be overridden; use {@link #addArgumentResolvers} instead.
651
656
* @since 4.3
652
657
*/
653
658
protected final List <HandlerMethodArgumentResolver > getArgumentResolvers () {
@@ -659,24 +664,21 @@ protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() {
659
664
}
660
665
661
666
/**
662
- * Add custom {@link HandlerMethodArgumentResolver}s to use in addition to
663
- * the ones registered by default.
664
- * <p>Custom argument resolvers are invoked before built-in resolvers
665
- * except for those that rely on the presence of annotations (e.g.
666
- * {@code @RequestParameter}, {@code @PathVariable}, etc.).
667
- * The latter can be customized by configuring the
667
+ * Add custom {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}
668
+ * to use in addition to the ones registered by default.
669
+ * <p>Custom argument resolvers are invoked before built-in resolvers except for
670
+ * those that rely on the presence of annotations (e.g. {@code @RequestParameter},
671
+ * {@code @PathVariable}, etc). The latter can be customized by configuring the
668
672
* {@link RequestMappingHandlerAdapter} directly.
669
- * @param argumentResolvers the list of custom converters;
670
- * initially an empty list.
673
+ * @param argumentResolvers the list of custom converters (initially an empty list)
671
674
*/
672
675
protected void addArgumentResolvers (List <HandlerMethodArgumentResolver > argumentResolvers ) {
673
676
}
674
677
675
678
/**
676
679
* Provide access to the shared return value handlers used by the
677
- * {@link RequestMappingHandlerAdapter} and the
678
- * {@link ExceptionHandlerExceptionResolver}. This method cannot be
679
- * overridden, use {@link #addReturnValueHandlers(List)} instead.
680
+ * {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
681
+ * <p>This method cannot be overridden; use {@link #addReturnValueHandlers} instead.
680
682
* @since 4.3
681
683
*/
682
684
protected final List <HandlerMethodReturnValueHandler > getReturnValueHandlers () {
@@ -688,27 +690,23 @@ protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() {
688
690
}
689
691
690
692
/**
691
- * Add custom {@link HandlerMethodReturnValueHandler}s in addition to the
692
- * ones registered by default.
693
- * <p>Custom return value handlers are invoked before built-in ones except
694
- * for those that rely on the presence of annotations (e.g.
695
- * {@code @ResponseBody}, {@code @ModelAttribute}, etc.).
696
- * The latter can be customized by configuring the
693
+ * Add custom {@link HandlerMethodReturnValueHandler HandlerMethodReturnValueHandlers}
694
+ * in addition to the ones registered by default.
695
+ * <p>Custom return value handlers are invoked before built-in ones except for
696
+ * those that rely on the presence of annotations (e.g. {@code @ResponseBody},
697
+ * {@code @ModelAttribute}, etc). The latter can be customized by configuring the
697
698
* {@link RequestMappingHandlerAdapter} directly.
698
- * @param returnValueHandlers the list of custom handlers;
699
- * initially an empty list.
699
+ * @param returnValueHandlers the list of custom handlers (initially an empty list)
700
700
*/
701
701
protected void addReturnValueHandlers (List <HandlerMethodReturnValueHandler > returnValueHandlers ) {
702
702
}
703
703
704
704
/**
705
- * Provides access to the shared {@link HttpMessageConverter}s used by the
706
- * {@link RequestMappingHandlerAdapter} and the
705
+ * Provides access to the shared {@link HttpMessageConverter HttpMessageConverters}
706
+ * used by the {@link RequestMappingHandlerAdapter} and the
707
707
* {@link ExceptionHandlerExceptionResolver}.
708
- * This method cannot be overridden.
709
- * Use {@link #configureMessageConverters(List)} instead.
710
- * Also see {@link #addDefaultHttpMessageConverters(List)} that can be
711
- * used to add default message converters.
708
+ * <p>This method cannot be overridden; use {@link #configureMessageConverters} instead.
709
+ * Also see {@link #addDefaultHttpMessageConverters} for adding default message converters.
712
710
*/
713
711
protected final List <HttpMessageConverter <?>> getMessageConverters () {
714
712
if (this .messageConverters == null ) {
@@ -723,32 +721,30 @@ protected final List<HttpMessageConverter<?>> getMessageConverters() {
723
721
}
724
722
725
723
/**
726
- * Override this method to add custom {@link HttpMessageConverter}s to use
727
- * with the {@link RequestMappingHandlerAdapter} and the
728
- * {@link ExceptionHandlerExceptionResolver}. Adding converters to the
729
- * list turns off the default converters that would otherwise be registered
730
- * by default. Also see {@link #addDefaultHttpMessageConverters(List)} that
731
- * can be used to add default message converters.
732
- * @param converters a list to add message converters to;
733
- * initially an empty list.
724
+ * Override this method to add custom {@link HttpMessageConverter HttpMessageConverters}
725
+ * to use with the {@link RequestMappingHandlerAdapter} and the
726
+ * {@link ExceptionHandlerExceptionResolver}.
727
+ * <p>Adding converters to the list turns off the default converters that would
728
+ * otherwise be registered by default. Also see {@link #addDefaultHttpMessageConverters}
729
+ * for adding default message converters.
730
+ * @param converters a list to add message converters to (initially an empty list)
734
731
*/
735
732
protected void configureMessageConverters (List <HttpMessageConverter <?>> converters ) {
736
733
}
737
734
738
735
/**
739
- * Override this method to extend or modify the list of converters after it
740
- * has been configured. This may be useful for example to allow default
741
- * converters to be registered and then insert a custom converter through
742
- * this method.
743
- * @param converters the list of configured converters to extend.
736
+ * Override this method to extend or modify the list of converters after it has
737
+ * been configured. This may be useful for example to allow default converters
738
+ * to be registered and then insert a custom converter through this method.
739
+ * @param converters the list of configured converters to extend
744
740
* @since 4.1.3
745
741
*/
746
742
protected void extendMessageConverters (List <HttpMessageConverter <?>> converters ) {
747
743
}
748
744
749
745
/**
750
746
* Adds a set of default HttpMessageConverter instances to the given list.
751
- * Subclasses can call this method from {@link #configureMessageConverters(List) }.
747
+ * Subclasses can call this method from {@link #configureMessageConverters}.
752
748
* @param messageConverters the list to add the default message converters to
753
749
*/
754
750
protected final void addDefaultHttpMessageConverters (List <HttpMessageConverter <?>> messageConverters ) {
@@ -813,14 +809,12 @@ public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() {
813
809
}
814
810
815
811
/**
816
- * Returns a {@link HandlerExceptionResolverComposite} containing a list
817
- * of exception resolvers obtained either through
818
- * {@link #configureHandlerExceptionResolvers(List)} or through
819
- * {@link #addDefaultHandlerExceptionResolvers(List)}.
820
- * <p><strong>Note:</strong> This method cannot be made final due to CGLib
821
- * constraints. Rather than overriding it, consider overriding
822
- * {@link #configureHandlerExceptionResolvers(List)}, which allows
823
- * providing a list of resolvers.
812
+ * Returns a {@link HandlerExceptionResolverComposite} containing a list of exception
813
+ * resolvers obtained either through {@link #configureHandlerExceptionResolvers} or
814
+ * through {@link #addDefaultHandlerExceptionResolvers}.
815
+ * <p><strong>Note:</strong> This method cannot be made final due to CGLIB constraints.
816
+ * Rather than overriding it, consider overriding {@link #configureHandlerExceptionResolvers}
817
+ * which allows for providing a list of resolvers.
824
818
*/
825
819
@ Bean
826
820
public HandlerExceptionResolver handlerExceptionResolver () {
@@ -838,29 +832,29 @@ public HandlerExceptionResolver handlerExceptionResolver() {
838
832
839
833
/**
840
834
* Override this method to configure the list of
841
- * {@link HandlerExceptionResolver}s to use. Adding resolvers to the list
842
- * turns off the default resolvers that would otherwise be registered by
843
- * default. Also see {@link #addDefaultHandlerExceptionResolvers(List) }
835
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers} to use.
836
+ * <p>Adding resolvers to the list turns off the default resolvers that would otherwise
837
+ * be registered by default. Also see {@link #addDefaultHandlerExceptionResolvers}
844
838
* that can be used to add the default exception resolvers.
845
- * @param exceptionResolvers a list to add exception resolvers to;
846
- * initially an empty list.
839
+ * @param exceptionResolvers a list to add exception resolvers to (initially an empty list)
847
840
*/
848
841
protected void configureHandlerExceptionResolvers (List <HandlerExceptionResolver > exceptionResolvers ) {
849
842
}
850
843
851
844
/**
852
845
* Override this method to extend or modify the list of
853
- * {@link HandlerExceptionResolver}s after it has been configured. This may
854
- * be useful for example to allow default resolvers to be registered and then
855
- * insert a custom one through this method.
846
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers} after it has been configured.
847
+ * <p>This may be useful for example to allow default resolvers to be registered
848
+ * and then insert a custom one through this method.
856
849
* @param exceptionResolvers the list of configured resolvers to extend.
857
850
* @since 4.3
858
851
*/
859
852
protected void extendHandlerExceptionResolvers (List <HandlerExceptionResolver > exceptionResolvers ) {
860
853
}
861
854
862
855
/**
863
- * A method available to subclasses for adding default {@link HandlerExceptionResolver}s.
856
+ * A method available to subclasses for adding default
857
+ * {@link HandlerExceptionResolver HandlerExceptionResolvers}.
864
858
* <p>Adds the following exception resolvers:
865
859
* <ul>
866
860
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through
@@ -963,7 +957,8 @@ protected final Map<String, CorsConfiguration> getCorsConfigurations() {
963
957
protected void addCorsMappings (CorsRegistry registry ) {
964
958
}
965
959
966
- @ Bean @ Lazy
960
+ @ Bean
961
+ @ Lazy
967
962
public HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
968
963
return new HandlerMappingIntrospector ();
969
964
}
0 commit comments