This commit is contained in:
Rossen Stoyanchev
2017-09-08 07:53:23 -04:00
parent 8f78c772b5
commit bc470fca30
6 changed files with 48 additions and 39 deletions

View File

@@ -243,13 +243,12 @@ public final class ModelFactory {
/**
* Derive the model attribute name for a method parameter based on:
* <ol>
* <li>the parameter {@code @ModelAttribute} annotation value
* <li>the parameter type
* </ol>
* Derive the model attribute name for the given method parameter based on
* a {@code @ModelAttribute} parameter annotation (if present) or falling
* back on parameter type based conventions.
* @param parameter a descriptor for the method parameter
* @return the derived name (never {@code null} or empty String)
* @return the derived name
* @see Conventions#getVariableNameForParameter(MethodParameter)
*/
public static String getNameForParameter(MethodParameter parameter) {
ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.class);

View File

@@ -74,10 +74,7 @@ public class SessionAttributesHandler {
this.attributeNames.addAll(Arrays.asList(annotation.names()));
this.attributeTypes.addAll(Arrays.asList(annotation.types()));
}
for (String attributeName : this.attributeNames) {
this.knownAttributeNames.add(attributeName);
}
this.knownAttributeNames.addAll(this.attributeNames);
}
/**
@@ -90,7 +87,7 @@ public class SessionAttributesHandler {
/**
* Whether the attribute name or type match the names and types specified
* via {@code @SessionAttributes} in underlying controller.
* via {@code @SessionAttributes} on the underlying controller.
* <p>Attributes successfully resolved through this method are "remembered"
* and subsequently used in {@link #retrieveAttributes(WebRequest)} and
* {@link #cleanupAttributes(WebRequest)}.