Polishing

This commit is contained in:
Juergen Hoeller 2016-03-24 21:44:16 +01:00
parent 852212d0c5
commit 775bcccd10
2 changed files with 13 additions and 11 deletions

View File

@ -328,6 +328,7 @@ public class DispatcherServlet extends FrameworkServlet {
/** List of ViewResolvers used by this servlet */ /** List of ViewResolvers used by this servlet */
private List<ViewResolver> viewResolvers; private List<ViewResolver> viewResolvers;
/** /**
* Create a new {@code DispatcherServlet} that will create its own internal web * Create a new {@code DispatcherServlet} that will create its own internal web
* application context based on defaults and values provided through servlet * application context based on defaults and values provided through servlet
@ -347,7 +348,7 @@ public class DispatcherServlet extends FrameworkServlet {
*/ */
public DispatcherServlet() { public DispatcherServlet() {
super(); super();
this.setDispatchOptionsRequest(true); setDispatchOptionsRequest(true);
} }
/** /**
@ -391,9 +392,10 @@ public class DispatcherServlet extends FrameworkServlet {
*/ */
public DispatcherServlet(WebApplicationContext webApplicationContext) { public DispatcherServlet(WebApplicationContext webApplicationContext) {
super(webApplicationContext); super(webApplicationContext);
this.setDispatchOptionsRequest(true); setDispatchOptionsRequest(true);
} }
/** /**
* Set whether to detect all HandlerMapping beans in this servlet's context. Otherwise, * Set whether to detect all HandlerMapping beans in this servlet's context. Otherwise,
* just a single bean with name "handlerMapping" will be expected. * just a single bean with name "handlerMapping" will be expected.
@ -465,6 +467,7 @@ public class DispatcherServlet extends FrameworkServlet {
this.cleanupAfterInclude = cleanupAfterInclude; this.cleanupAfterInclude = cleanupAfterInclude;
} }
/** /**
* This implementation calls {@link #initStrategies}. * This implementation calls {@link #initStrategies}.
*/ */
@ -549,9 +552,8 @@ public class DispatcherServlet extends FrameworkServlet {
// We need to use the default. // We need to use the default.
this.themeResolver = getDefaultStrategy(context, ThemeResolver.class); this.themeResolver = getDefaultStrategy(context, ThemeResolver.class);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug("Unable to locate ThemeResolver with name '" + THEME_RESOLVER_BEAN_NAME +
"Unable to locate ThemeResolver with name '" + THEME_RESOLVER_BEAN_NAME + "': using default [" + "': using default [" + this.themeResolver + "]");
this.themeResolver + "]");
} }
} }
} }
@ -739,8 +741,7 @@ public class DispatcherServlet extends FrameworkServlet {
*/ */
private void initFlashMapManager(ApplicationContext context) { private void initFlashMapManager(ApplicationContext context) {
try { try {
this.flashMapManager = this.flashMapManager = context.getBean(FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class);
context.getBean(FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Using FlashMapManager [" + this.flashMapManager + "]"); logger.debug("Using FlashMapManager [" + this.flashMapManager + "]");
} }
@ -840,7 +841,8 @@ public class DispatcherServlet extends FrameworkServlet {
/** /**
* Create a default strategy. * Create a default strategy.
* <p>The default implementation uses {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}. * <p>The default implementation uses
* {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}.
* @param context the current WebApplicationContext * @param context the current WebApplicationContext
* @param clazz the strategy implementation class to instantiate * @param clazz the strategy implementation class to instantiate
* @return the fully configured strategy instance * @return the fully configured strategy instance
@ -1101,7 +1103,8 @@ public class DispatcherServlet extends FrameworkServlet {
* @see MultipartResolver#cleanupMultipart * @see MultipartResolver#cleanupMultipart
*/ */
protected void cleanupMultipart(HttpServletRequest request) { protected void cleanupMultipart(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class); MultipartHttpServletRequest multipartRequest =
WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class);
if (multipartRequest != null) { if (multipartRequest != null) {
this.multipartResolver.cleanupMultipart(multipartRequest); this.multipartResolver.cleanupMultipart(multipartRequest);
} }

View File

@ -46,7 +46,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ConfigurableWebEnvironment; import org.springframework.web.context.ConfigurableWebEnvironment;
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
@ -919,7 +918,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
@Override @Override
public void setHeader(String name, String value) { public void setHeader(String name, String value) {
if ("Allow".equals(name)) { if ("Allow".equals(name)) {
value = (StringUtils.hasLength(value) ? value + ", " : "") + RequestMethod.PATCH.name(); value = (StringUtils.hasLength(value) ? value + ", " : "") + HttpMethod.PATCH.name();
} }
super.setHeader(name, value); super.setHeader(name, value);
} }