From ccaa5043783be7de0284ec0d2820506088a17272 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 24 Mar 2016 21:44:16 +0100 Subject: [PATCH] Polishing (cherry picked from commit 775bccc) --- .../web/servlet/DispatcherServlet.java | 19 +++++++++++-------- .../web/servlet/FrameworkServlet.java | 3 +-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 0143fdc8689..7fd9424807e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -328,6 +328,7 @@ public class DispatcherServlet extends FrameworkServlet { /** List of ViewResolvers used by this servlet */ private List viewResolvers; + /** * Create a new {@code DispatcherServlet} that will create its own internal web * application context based on defaults and values provided through servlet @@ -392,6 +393,7 @@ public class DispatcherServlet extends FrameworkServlet { super(webApplicationContext); } + /** * Set whether to detect all HandlerMapping beans in this servlet's context. Otherwise, * just a single bean with name "handlerMapping" will be expected. @@ -463,6 +465,7 @@ public class DispatcherServlet extends FrameworkServlet { this.cleanupAfterInclude = cleanupAfterInclude; } + /** * This implementation calls {@link #initStrategies}. */ @@ -547,9 +550,8 @@ public class DispatcherServlet extends FrameworkServlet { // We need to use the default. this.themeResolver = getDefaultStrategy(context, ThemeResolver.class); if (logger.isDebugEnabled()) { - logger.debug( - "Unable to locate ThemeResolver with name '" + THEME_RESOLVER_BEAN_NAME + "': using default [" + - this.themeResolver + "]"); + logger.debug("Unable to locate ThemeResolver with name '" + THEME_RESOLVER_BEAN_NAME + + "': using default [" + this.themeResolver + "]"); } } } @@ -737,8 +739,7 @@ public class DispatcherServlet extends FrameworkServlet { */ private void initFlashMapManager(ApplicationContext context) { try { - this.flashMapManager = - context.getBean(FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class); + this.flashMapManager = context.getBean(FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class); if (logger.isDebugEnabled()) { logger.debug("Using FlashMapManager [" + this.flashMapManager + "]"); } @@ -838,7 +839,8 @@ public class DispatcherServlet extends FrameworkServlet { /** * Create a default strategy. - *

The default implementation uses {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}. + *

The default implementation uses + * {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}. * @param context the current WebApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance @@ -1099,7 +1101,8 @@ public class DispatcherServlet extends FrameworkServlet { * @see MultipartResolver#cleanupMultipart */ protected void cleanupMultipart(HttpServletRequest request) { - MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class); + MultipartHttpServletRequest multipartRequest = + WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class); if (multipartRequest != null) { this.multipartResolver.cleanupMultipart(multipartRequest); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java index b880be50509..0cf705a947b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java @@ -46,7 +46,6 @@ import org.springframework.http.HttpMethod; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebEnvironment; import org.springframework.web.context.ContextLoader; @@ -916,7 +915,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @Override public void setHeader(String name, String value) { if ("Allow".equals(name)) { - value = (StringUtils.hasLength(value) ? value + ", " : "") + RequestMethod.PATCH.name(); + value = (StringUtils.hasLength(value) ? value + ", " : "") + HttpMethod.PATCH.name(); } super.setHeader(name, value); }