Introduce alias for 'value' attribute in @CookieValue
Issue: SPR-11393
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -22,14 +22,18 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Annotation which indicates that a method parameter should be bound to an HTTP cookie.
|
||||
* Supported for annotated handler methods in Servlet and Portlet environments.
|
||||
*
|
||||
* <p>Supported for annotated handler methods in Servlet and Portlet environments.
|
||||
*
|
||||
* <p>The method parameter may be declared as type {@link javax.servlet.http.Cookie}
|
||||
* or as cookie value type (String, int, etc).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
* @see RequestMapping
|
||||
* @see RequestParam
|
||||
@@ -45,10 +49,18 @@ import java.lang.annotation.Target;
|
||||
public @interface CookieValue {
|
||||
|
||||
/**
|
||||
* The name of the cookie to bind to.
|
||||
* Alias for {@link #name}.
|
||||
*/
|
||||
@AliasFor(attribute = "name")
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* The name of the cookie to bind to.
|
||||
* @since 4.2
|
||||
*/
|
||||
@AliasFor(attribute = "value")
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* Whether the header is required.
|
||||
* <p>Default is {@code true}, leading to an exception being thrown
|
||||
|
||||
@@ -278,7 +278,7 @@ public class HandlerMethodInvoker {
|
||||
}
|
||||
else if (CookieValue.class.isInstance(paramAnn)) {
|
||||
CookieValue cookieValue = (CookieValue) paramAnn;
|
||||
cookieName = cookieValue.value();
|
||||
cookieName = cookieValue.name();
|
||||
required = cookieValue.required();
|
||||
defaultValue = parseDefaultValueAttribute(cookieValue.defaultValue());
|
||||
annotationsFound++;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractCookieValueMethodArgumentResolver extends Abstract
|
||||
private static class CookieValueNamedValueInfo extends NamedValueInfo {
|
||||
|
||||
private CookieValueNamedValueInfo(CookieValue annotation) {
|
||||
super(annotation.value(), annotation.required(), annotation.defaultValue());
|
||||
super(annotation.name(), annotation.required(), annotation.defaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user