提交 3f11fbaf 编写于 作者: R Rossen Stoyanchev

Predictable index position for BindingResult keys and parameter annotation...

Predictable index position for BindingResult keys and parameter annotation convenience methods in MethodParameter
上级 006cbb25
......@@ -19,8 +19,8 @@ package org.springframework.validation;
import java.beans.PropertyEditor;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -270,11 +270,11 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
* @see org.springframework.web.servlet.mvc.SimpleFormController
*/
public Map<String, Object> getModel() {
Map<String, Object> model = new HashMap<String, Object>(2);
// Errors instance, even if no errors.
model.put(MODEL_KEY_PREFIX + getObjectName(), this);
Map<String, Object> model = new LinkedHashMap<String, Object>(2);
// Mapping from name to target object.
model.put(getObjectName(), getTarget());
// Errors instance, even if no errors.
model.put(MODEL_KEY_PREFIX + getObjectName(), this);
return model;
}
......
......@@ -278,6 +278,20 @@ public class MethodParameter {
return null;
}
/**
* Return true if the parameter has at least one annotation, false if it has none.
*/
public boolean hasParameterAnnotations() {
return getParameterAnnotations().length != 0;
}
/**
* Return true if the parameter has the given annotation type, and false if it doesn't.
*/
public <T extends Annotation> boolean hasParameterAnnotation(Class<T> annotationType) {
return getParameterAnnotation(annotationType) != null;
}
/**
* Initialize parameter name discovery for this method parameter.
* <p>This method does not actually try to retrieve the parameter name at
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册