Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -39,16 +39,15 @@ public class AsyncTaskMethodReturnValueHandler implements HandlerMethodReturnVal
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
Class<?> paramType = returnType.getParameterType();
|
||||
return WebAsyncTask.class.isAssignableFrom(paramType);
|
||||
return WebAsyncTask.class.isAssignableFrom(returnType.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue,
|
||||
MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -34,14 +34,12 @@ public class CallableMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
Class<?> paramType = returnType.getParameterType();
|
||||
return Callable.class.isAssignableFrom(paramType);
|
||||
return Callable.class.isAssignableFrom(returnType.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue,
|
||||
MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
@@ -33,14 +33,12 @@ public class DeferredResultMethodReturnValueHandler implements HandlerMethodRetu
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
Class<?> paramType = returnType.getParameterType();
|
||||
return DeferredResult.class.isAssignableFrom(paramType);
|
||||
return DeferredResult.class.isAssignableFrom(returnType.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue,
|
||||
MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -36,14 +36,12 @@ public class ListenableFutureReturnValueHandler implements HandlerMethodReturnVa
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
Class<?> paramType = returnType.getParameterType();
|
||||
return ListenableFuture.class.isAssignableFrom(paramType);
|
||||
return ListenableFuture.class.isAssignableFrom(returnType.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue,
|
||||
MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -50,11 +50,9 @@ public class ModelAndViewMethodReturnValueHandler implements HandlerMethodReturn
|
||||
* Configure one more simple patterns (as described in
|
||||
* {@link org.springframework.util.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(String... redirectPatterns) {
|
||||
@@ -75,10 +73,8 @@ public class ModelAndViewMethodReturnValueHandler implements HandlerMethodReturn
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(
|
||||
Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
|
||||
throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -57,6 +57,7 @@ public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMeth
|
||||
|
||||
private final ModelAttributeMethodProcessor modelAttributeProcessor = new ModelAttributeMethodProcessor(true);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
@@ -64,6 +65,7 @@ public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMeth
|
||||
this.mavResolvers = mavResolvers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Always returns {@code true}. See class-level note.
|
||||
*/
|
||||
@@ -73,17 +75,15 @@ public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMeth
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(
|
||||
Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest request)
|
||||
throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (this.mavResolvers != null) {
|
||||
for (ModelAndViewResolver mavResolver : this.mavResolvers) {
|
||||
Class<?> handlerType = returnType.getContainingClass();
|
||||
Method method = returnType.getMethod();
|
||||
ExtendedModelMap model = (ExtendedModelMap) mavContainer.getModel();
|
||||
ModelAndView mav = mavResolver.resolveModelAndView(method, handlerType, returnValue, model, request);
|
||||
ModelAndView mav = mavResolver.resolveModelAndView(method, handlerType, returnValue, model, webRequest);
|
||||
if (mav != ModelAndViewResolver.UNRESOLVED) {
|
||||
mavContainer.addAllAttributes(mav.getModel());
|
||||
mavContainer.setViewName(mav.getViewName());
|
||||
@@ -97,7 +97,7 @@ public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMeth
|
||||
|
||||
// No suitable ModelAndViewResolver...
|
||||
if (this.modelAttributeProcessor.supportsReturnType(returnType)) {
|
||||
this.modelAttributeProcessor.handleReturnValue(returnValue, returnType, mavContainer, request);
|
||||
this.modelAttributeProcessor.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("Unexpected return type: " +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -44,9 +44,9 @@ public class PathVariableMapMethodArgumentResolver implements HandlerMethodArgum
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
PathVariable annot = parameter.getParameterAnnotation(PathVariable.class);
|
||||
return ((annot != null) && (Map.class.isAssignableFrom(parameter.getParameterType()))
|
||||
&& (!StringUtils.hasText(annot.value())));
|
||||
PathVariable ann = parameter.getParameterAnnotation(PathVariable.class);
|
||||
return (ann != null && (Map.class.isAssignableFrom(parameter.getParameterType()))
|
||||
&& !StringUtils.hasText(ann.value()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -32,10 +32,12 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
|
||||
/**
|
||||
* Resolves method arguments of type {@link RedirectAttributes}.
|
||||
*
|
||||
* <p>This resolver must be listed ahead of {@link org.springframework.web.method.annotation.ModelMethodProcessor} and
|
||||
* {@link org.springframework.web.method.annotation.MapMethodProcessor}, which support {@link Map} and {@link Model}
|
||||
* arguments both of which are "super" types of {@code RedirectAttributes}
|
||||
* and would also attempt to resolve a {@code RedirectAttributes} argument.
|
||||
* <p>This resolver must be listed ahead of
|
||||
* {@link org.springframework.web.method.annotation.ModelMethodProcessor} and
|
||||
* {@link org.springframework.web.method.annotation.MapMethodProcessor},
|
||||
* which support {@link Map} and {@link Model} arguments both of which are
|
||||
* "super" types of {@code RedirectAttributes} and would also attempt to
|
||||
* resolve a {@code RedirectAttributes} argument.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
@@ -48,10 +50,8 @@ public class RedirectAttributesMethodArgumentResolver implements HandlerMethodAr
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(
|
||||
MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
|
||||
throws Exception {
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
DataBinder dataBinder = binderFactory.createBinder(webRequest, null, null);
|
||||
ModelMap redirectAttributes = new RedirectAttributesModelMap(dataBinder);
|
||||
|
||||
@@ -69,11 +69,13 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
|
||||
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
|
||||
ContentNegotiationManager contentNegotiationManager) {
|
||||
|
||||
super(messageConverters, contentNegotiationManager);
|
||||
}
|
||||
|
||||
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
|
||||
ContentNegotiationManager contentNegotiationManager, List<Object> responseBodyAdvice) {
|
||||
|
||||
super(messageConverters, contentNegotiationManager, responseBodyAdvice);
|
||||
}
|
||||
|
||||
@@ -85,12 +87,11 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return ((AnnotationUtils.findAnnotation(returnType.getContainingClass(), ResponseBody.class) != null) ||
|
||||
(returnType.getMethodAnnotation(ResponseBody.class) != null));
|
||||
return (AnnotationUtils.findAnnotation(returnType.getContainingClass(), ResponseBody.class) != null ||
|
||||
returnType.getMethodAnnotation(ResponseBody.class) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws MethodArgumentNotValidException if validation fails
|
||||
* @throws HttpMessageNotReadableException if {@link RequestBody#required()}
|
||||
* is {@code true} and there is no body content or if there is no suitable
|
||||
@@ -101,25 +102,20 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
Object argument = readWithMessageConverters(webRequest, parameter, parameter.getGenericParameterType());
|
||||
|
||||
String name = Conventions.getVariableNameForParameter(parameter);
|
||||
WebDataBinder binder = binderFactory.createBinder(webRequest, argument, name);
|
||||
|
||||
if (argument != null) {
|
||||
validate(binder, parameter);
|
||||
}
|
||||
|
||||
mavContainer.addAttribute(BindingResult.MODEL_KEY_PREFIX + name, binder.getBindingResult());
|
||||
|
||||
return argument;
|
||||
}
|
||||
|
||||
private void validate(WebDataBinder binder, MethodParameter parameter) throws Exception, MethodArgumentNotValidException {
|
||||
|
||||
private void validate(WebDataBinder binder, MethodParameter parameter) throws Exception {
|
||||
Annotation[] annotations = parameter.getParameterAnnotations();
|
||||
for (Annotation annot : annotations) {
|
||||
if (annot.annotationType().getSimpleName().startsWith("Valid")) {
|
||||
Object hints = AnnotationUtils.getValue(annot);
|
||||
for (Annotation ann : annotations) {
|
||||
if (ann.annotationType().getSimpleName().startsWith("Valid")) {
|
||||
Object hints = AnnotationUtils.getValue(ann);
|
||||
binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
|
||||
BindingResult bindingResult = binder.getBindingResult();
|
||||
if (bindingResult.hasErrors()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -36,7 +35,7 @@ import org.springframework.web.method.annotation.ModelAttributeMethodProcessor;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
/**
|
||||
* A Servlet-specific {@link org.springframework.web.method.annotation.ModelAttributeMethodProcessor} that applies data
|
||||
* A Servlet-specific {@link ModelAttributeMethodProcessor} that applies data
|
||||
* binding through a WebDataBinder of type {@link ServletRequestDataBinder}.
|
||||
*
|
||||
* <p>Also adds a fall-back strategy to instantiate the model attribute from a
|
||||
@@ -57,6 +56,7 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
super(annotationNotRequired);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiate the model attribute from a URI template variable or from a
|
||||
* request parameter if the name matches to the model attribute name and
|
||||
@@ -65,10 +65,8 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
* @see #createAttributeFromRequestValue(String, String, MethodParameter, WebDataBinderFactory, NativeWebRequest)
|
||||
*/
|
||||
@Override
|
||||
protected final Object createAttribute(String attributeName,
|
||||
MethodParameter parameter,
|
||||
WebDataBinderFactory binderFactory,
|
||||
NativeWebRequest request) throws Exception {
|
||||
protected final Object createAttribute(String attributeName, MethodParameter parameter,
|
||||
WebDataBinderFactory binderFactory, NativeWebRequest request) throws Exception {
|
||||
|
||||
String value = getRequestValueForAttribute(attributeName, request);
|
||||
if (value != null) {
|
||||
@@ -106,9 +104,9 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final Map<String, String> getUriTemplateVariables(NativeWebRequest request) {
|
||||
Map<String, String> variables =
|
||||
(Map<String, String>) request.getAttribute(
|
||||
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
|
||||
return (variables != null) ? variables : Collections.<String, String>emptyMap();
|
||||
(Map<String, String>) request.getAttribute(
|
||||
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
|
||||
return (variables != null ? variables : Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,11 +122,10 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
* @return the created model attribute, or {@code null}
|
||||
* @throws Exception
|
||||
*/
|
||||
protected Object createAttributeFromRequestValue(String sourceValue,
|
||||
String attributeName,
|
||||
MethodParameter parameter,
|
||||
WebDataBinderFactory binderFactory,
|
||||
NativeWebRequest request) throws Exception {
|
||||
protected Object createAttributeFromRequestValue(String sourceValue, String attributeName,
|
||||
MethodParameter parameter, WebDataBinderFactory binderFactory, NativeWebRequest request)
|
||||
throws Exception {
|
||||
|
||||
DataBinder binder = binderFactory.createBinder(request, null, attributeName);
|
||||
ConversionService conversionService = binder.getConversionService();
|
||||
if (conversionService != null) {
|
||||
@@ -142,8 +139,8 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>Downcast {@link WebDataBinder} to {@link ServletRequestDataBinder} before binding.
|
||||
* This implementation downcasts {@link WebDataBinder} to
|
||||
* {@link ServletRequestDataBinder} before binding.
|
||||
* @see ServletRequestDataBinderFactory
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.security.Principal;
|
||||
@@ -65,7 +64,7 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
Class<?> paramType = parameter.getParameterType();
|
||||
return WebRequest.class.isAssignableFrom(paramType) ||
|
||||
return (WebRequest.class.isAssignableFrom(paramType) ||
|
||||
ServletRequest.class.isAssignableFrom(paramType) ||
|
||||
MultipartRequest.class.isAssignableFrom(paramType) ||
|
||||
HttpSession.class.isAssignableFrom(paramType) ||
|
||||
@@ -75,14 +74,12 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
|
||||
"java.time.ZoneId".equals(paramType.getName()) ||
|
||||
InputStream.class.isAssignableFrom(paramType) ||
|
||||
Reader.class.isAssignableFrom(paramType) ||
|
||||
HttpMethod.class.equals(paramType);
|
||||
HttpMethod.class.equals(paramType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(
|
||||
MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
|
||||
throws IOException {
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
Class<?> paramType = parameter.getParameterType();
|
||||
if (WebRequest.class.isAssignableFrom(paramType)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -47,9 +45,9 @@ public class ServletResponseMethodArgumentResolver implements HandlerMethodArgum
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
Class<?> paramType = parameter.getParameterType();
|
||||
return ServletResponse.class.isAssignableFrom(paramType)
|
||||
|| OutputStream.class.isAssignableFrom(paramType)
|
||||
|| Writer.class.isAssignableFrom(paramType);
|
||||
return (ServletResponse.class.isAssignableFrom(paramType) ||
|
||||
OutputStream.class.isAssignableFrom(paramType) ||
|
||||
Writer.class.isAssignableFrom(paramType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,10 +57,8 @@ public class ServletResponseMethodArgumentResolver implements HandlerMethodArgum
|
||||
* {@code null}, the request is considered directly handled.
|
||||
*/
|
||||
@Override
|
||||
public Object resolveArgument(
|
||||
MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
|
||||
throws IOException {
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
if (mavContainer != null) {
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -43,10 +43,8 @@ public class UriComponentsBuilderMethodArgumentResolver implements HandlerMethod
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(
|
||||
MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
|
||||
throws Exception {
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
|
||||
return ServletUriComponentsBuilder.fromServletMapping(request);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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,10 +46,8 @@ public class ViewMethodReturnValueHandler implements HandlerMethodReturnValueHan
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(
|
||||
Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
|
||||
throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
return;
|
||||
|
||||
@@ -48,11 +48,9 @@ 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.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public void setRedirectPatterns(String... redirectPatterns) {
|
||||
@@ -66,6 +64,7 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
return this.redirectPatterns;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
Class<?> paramType = returnType.getParameterType();
|
||||
@@ -73,10 +72,8 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(
|
||||
Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
|
||||
throws Exception {
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
if (returnValue == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user