Polishing

This commit is contained in:
Juergen Hoeller
2014-09-17 02:35:41 +02:00
parent d1c720c07b
commit 15320db414
10 changed files with 52 additions and 41 deletions

View File

@@ -116,7 +116,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth
@Override
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
throw new ServletRequestBindingException("Missing matrix variable '" + name +
"' for method parameter type " + parameter.getParameterType().getSimpleName());
"' for method parameter of type " + parameter.getParameterType().getSimpleName());
}

View File

@@ -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.
@@ -103,7 +103,7 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
@Override
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
throw new ServletRequestBindingException("Missing URI template variable '" + name +
"' for method parameter type " + parameter.getParameterType().getSimpleName());
"' for method parameter of type " + parameter.getParameterType().getSimpleName());
}
@Override
@@ -122,16 +122,16 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
}
@Override
public void contributeMethodArgument(MethodParameter param, Object value,
UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService cs) {
public void contributeMethodArgument(MethodParameter parameter, Object value,
UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
if (Map.class.isAssignableFrom(param.getParameterType())) {
if (Map.class.isAssignableFrom(parameter.getParameterType())) {
return;
}
PathVariable annot = param.getParameterAnnotation(PathVariable.class);
String name = (StringUtils.isEmpty(annot.value()) ? param.getParameterName() : annot.value());
value = formatUriValue(cs, new TypeDescriptor(param), value);
PathVariable ann = parameter.getParameterAnnotation(PathVariable.class);
String name = (ann == null || StringUtils.isEmpty(ann.value()) ? parameter.getParameterName() : ann.value());
value = formatUriValue(conversionService, new TypeDescriptor(parameter), value);
uriVariables.put(name, value);
}

View File

@@ -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.
@@ -27,8 +27,8 @@ import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.WebUtils;
/**
* An {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver} that resolves cookie
* values from an {@link HttpServletRequest}.
* An {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver}
* that resolves cookie values from an {@link HttpServletRequest}.
*
* @author Rossen Stoyanchev
* @since 3.1
@@ -37,17 +37,19 @@ public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValu
private UrlPathHelper urlPathHelper = new UrlPathHelper();
public ServletCookieValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory) {
super(beanFactory);
}
public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper;
}
@Override
protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest)
throws Exception {
protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) throws Exception {
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
Cookie cookieValue = WebUtils.getCookie(servletRequest, cookieName);
if (Cookie.class.isAssignableFrom(parameter.getParameterType())) {
@@ -60,4 +62,5 @@ public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValu
return null;
}
}
}