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.
|
||||
@@ -114,10 +114,9 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMissingValue(String name, MethodParameter param) throws ServletRequestBindingException {
|
||||
String paramType = param.getParameterType().getName();
|
||||
throw new ServletRequestBindingException(
|
||||
"Missing matrix variable '" + name + "' for method parameter type [" + paramType + "]");
|
||||
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
|
||||
throw new ServletRequestBindingException("Missing matrix variable '" + name +
|
||||
"' for method parameter of type " + parameter.getParameterType().getSimpleName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -101,10 +101,9 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMissingValue(String name, MethodParameter param) throws ServletRequestBindingException {
|
||||
String paramType = param.getParameterType().getName();
|
||||
throw new ServletRequestBindingException(
|
||||
"Missing URI template variable '" + name + "' for method parameter type [" + paramType + "]");
|
||||
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
|
||||
throw new ServletRequestBindingException("Missing URI template variable '" + name +
|
||||
"' for method parameter of type " + parameter.getParameterType().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,8 +129,8 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
return;
|
||||
}
|
||||
|
||||
PathVariable annot = parameter.getParameterAnnotation(PathVariable.class);
|
||||
String name = StringUtils.isEmpty(annot.value()) ? parameter.getParameterName() : annot.value();
|
||||
PathVariable ann = parameter.getParameterAnnotation(PathVariable.class);
|
||||
String name = (ann == null || StringUtils.isEmpty(ann.value()) ? parameter.getParameterName() : ann.value());
|
||||
|
||||
if (conversionService != null) {
|
||||
value = conversionService.convert(value, new TypeDescriptor(parameter), STRING_TYPE_DESCRIPTOR);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user