Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -960,7 +960,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
else {
|
||||
params = (request.getParameterMap().isEmpty() ? "" : "masked");
|
||||
params = (request.getParameterMap().isEmpty() ? "" : "masked");
|
||||
}
|
||||
|
||||
String query = StringUtils.isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString();
|
||||
@@ -1166,7 +1166,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
logger.trace("Request already resolved to MultipartHttpServletRequest, e.g. by MultipartFilter");
|
||||
}
|
||||
}
|
||||
else if (hasMultipartException(request) ) {
|
||||
else if (hasMultipartException(request)) {
|
||||
logger.debug("Multipart resolution previously failed for current request - " +
|
||||
"skipping re-resolution for undisturbed error rendering");
|
||||
}
|
||||
@@ -1432,7 +1432,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
* @param attributesSnapshot the snapshot of the request attributes before the include
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?> attributesSnapshot) {
|
||||
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?, ?> attributesSnapshot) {
|
||||
// Need to copy into separate Collection here, to avoid side effects
|
||||
// on the Enumeration when removing attributes.
|
||||
Set<String> attrsToCheck = new HashSet<>();
|
||||
@@ -1451,7 +1451,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
// or removing the attribute, respectively, if appropriate.
|
||||
for (String attrName : attrsToCheck) {
|
||||
Object attrValue = attributesSnapshot.get(attrName);
|
||||
if (attrValue == null){
|
||||
if (attrValue == null) {
|
||||
request.removeAttribute(attrName);
|
||||
}
|
||||
else if (attrValue != request.getAttribute(attrName)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -213,7 +213,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
configurePathMatchingProperties(handlerMappingDef, element, context);
|
||||
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME , handlerMappingDef);
|
||||
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME, handlerMappingDef);
|
||||
|
||||
RuntimeBeanReference corsRef = MvcNamespaceUtils.registerCorsConfigurations(null, context, source);
|
||||
handlerMappingDef.getPropertyValues().add("corsConfigurations", corsRef);
|
||||
@@ -265,7 +265,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
handlerAdapterDef.getPropertyValues().add("callableInterceptors", callableInterceptors);
|
||||
handlerAdapterDef.getPropertyValues().add("deferredResultInterceptors", deferredResultInterceptors);
|
||||
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef);
|
||||
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME, handlerAdapterDef);
|
||||
|
||||
RootBeanDefinition uriContributorDef =
|
||||
new RootBeanDefinition(CompositeUriComponentsContributorFactoryBean.class);
|
||||
@@ -391,7 +391,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
factoryBeanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
factoryBeanDef.getPropertyValues().add("mediaTypes", getDefaultMediaTypes());
|
||||
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME;
|
||||
context.getReaderContext().getRegistry().registerBeanDefinition(name , factoryBeanDef);
|
||||
context.getReaderContext().getRegistry().registerBeanDefinition(name, factoryBeanDef);
|
||||
context.registerComponent(new BeanComponentDefinition(factoryBeanDef, name));
|
||||
beanRef = new RuntimeBeanReference(name);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -82,8 +82,8 @@ public abstract class MvcNamespaceUtils {
|
||||
}
|
||||
parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
|
||||
}
|
||||
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)
|
||||
&& !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
|
||||
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) &&
|
||||
!parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
|
||||
RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class);
|
||||
urlPathHelperDef.setSource(source);
|
||||
urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
@@ -107,8 +107,8 @@ public abstract class MvcNamespaceUtils {
|
||||
}
|
||||
parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
|
||||
}
|
||||
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
|
||||
&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
|
||||
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) &&
|
||||
!parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
|
||||
RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
|
||||
pathMatcherDef.setSource(source);
|
||||
pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
@@ -123,7 +123,7 @@ public abstract class MvcNamespaceUtils {
|
||||
* name unless already registered.
|
||||
*/
|
||||
private static void registerBeanNameUrlHandlerMapping(ParserContext context, @Nullable Object source) {
|
||||
if (!context.getRegistry().containsBeanDefinition(BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME)){
|
||||
if (!context.getRegistry().containsBeanDefinition(BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME)) {
|
||||
RootBeanDefinition mappingDef = new RootBeanDefinition(BeanNameUrlHandlerMapping.class);
|
||||
mappingDef.setSource(source);
|
||||
mappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
@@ -195,7 +195,7 @@ public abstract class MvcNamespaceUtils {
|
||||
* unless already registered.
|
||||
*/
|
||||
private static void registerHandlerMappingIntrospector(ParserContext parserContext, @Nullable Object source) {
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)){
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) {
|
||||
RootBeanDefinition beanDef = new RootBeanDefinition(HandlerMappingIntrospector.class);
|
||||
beanDef.setSource(source);
|
||||
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -179,7 +179,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
}
|
||||
else if (useTrailingSlashMatch()) {
|
||||
if (!registeredPattern.endsWith("/") && getPathMatcher().match(registeredPattern + "/", urlPath)) {
|
||||
matchingPatterns.add(registeredPattern +"/");
|
||||
matchingPatterns.add(registeredPattern + "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -67,13 +67,12 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv
|
||||
|
||||
/**
|
||||
* Resolve the exception by iterating over the list of configured exception resolvers.
|
||||
* <p>The first one to return a {@link ModelAndView} wins. Otherwise {@code null}
|
||||
* is returned.
|
||||
* <p>The first one to return a {@link ModelAndView} wins. Otherwise {@code null} is returned.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
|
||||
@Nullable Object handler,Exception ex) {
|
||||
public ModelAndView resolveException(
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
|
||||
|
||||
if (this.resolvers != null) {
|
||||
for (HandlerExceptionResolver handlerExceptionResolver : this.resolvers) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -256,7 +256,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
}
|
||||
if (this.useTrailingSlashMatch) {
|
||||
if (!pattern.endsWith("/") && this.pathMatcher.match(pattern + "/", lookupPath)) {
|
||||
return pattern +"/";
|
||||
return pattern + "/";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -46,7 +46,7 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategy
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String simpleTypeName = handlerMethod.getBeanType().getSimpleName();
|
||||
for (int i = 0 ; i < simpleTypeName.length(); i++) {
|
||||
for (int i = 0; i < simpleTypeName.length(); i++) {
|
||||
if (Character.isUpperCase(simpleTypeName.charAt(i))) {
|
||||
sb.append(simpleTypeName.charAt(i));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -127,7 +127,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
* resolution use {@link #setArgumentResolvers} instead.
|
||||
*/
|
||||
public void setCustomArgumentResolvers(@Nullable List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
this.customArgumentResolvers= argumentResolvers;
|
||||
this.customArgumentResolvers = argumentResolvers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -50,14 +50,14 @@ public class SessionAttributeMethodArgumentResolver extends AbstractNamedValueMe
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request){
|
||||
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) {
|
||||
return request.getAttribute(name, RequestAttributes.SCOPE_SESSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletException {
|
||||
throw new ServletRequestBindingException("Missing session attribute '" + name +
|
||||
"' of type " + parameter.getNestedParameterType().getSimpleName());
|
||||
"' of type " + parameter.getNestedParameterType().getSimpleName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -50,7 +50,7 @@ public class ViewMethodReturnValueHandler implements HandlerMethodReturnValueHan
|
||||
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue instanceof View){
|
||||
if (returnValue instanceof View) {
|
||||
View view = (View) returnValue;
|
||||
mavContainer.setView(view);
|
||||
if (view instanceof SmartView && ((SmartView) view).isRedirectView()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -33,10 +33,10 @@ import org.springframework.web.servlet.RequestToViewNameTranslator;
|
||||
* as the actual return value is left as-is allowing the configured
|
||||
* {@link RequestToViewNameTranslator} to select a view name by convention.
|
||||
*
|
||||
* <p>A String return value can be interpreted in more than one ways depending
|
||||
* on the presence of annotations like {@code @ModelAttribute} or
|
||||
* {@code @ResponseBody}. Therefore this handler should be configured after
|
||||
* the handlers that support these annotations.
|
||||
* <p>A String return value can be interpreted in more than one ways depending on
|
||||
* the presence of annotations like {@code @ModelAttribute} or {@code @ResponseBody}.
|
||||
* Therefore this handler should be configured after the handlers that support these
|
||||
* annotations.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
@@ -49,12 +49,10 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
|
||||
|
||||
/**
|
||||
* Configure one more simple patterns (as described in
|
||||
* {@link PatternMatchUtils#simpleMatch}) to use in order to recognize
|
||||
* custom redirect prefixes in addition to "redirect:".
|
||||
* <p>Note that simply configuring this property will not make a custom
|
||||
* redirect prefix work. There must be a custom View that recognizes the
|
||||
* prefix as well.
|
||||
* Configure one more simple patterns (as described in {@link PatternMatchUtils#simpleMatch})
|
||||
* to use in order to recognize custom redirect prefixes in addition to "redirect:".
|
||||
* <p>Note that simply configuring this property will not make a custom redirect prefix work.
|
||||
* There must be a custom View that recognizes the prefix as well.
|
||||
* @since 4.1
|
||||
*/
|
||||
public void setRedirectPatterns(@Nullable String... redirectPatterns) {
|
||||
@@ -87,7 +85,7 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
mavContainer.setRedirectModelScenario(true);
|
||||
}
|
||||
}
|
||||
else if (returnValue != null){
|
||||
else if (returnValue != null) {
|
||||
// should not happen
|
||||
throw new UnsupportedOperationException("Unexpected return type: " +
|
||||
returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
|
||||
|
||||
Reference in New Issue
Block a user