public class AllowedParamsModelAttributeMethodProcessor extends Object implements org.springframework.web.method.support.HandlerMethodArgumentResolver, org.springframework.web.method.support.HandlerMethodReturnValueHandler
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.slf4j.Logger |
logger |
| 构造器和说明 |
|---|
AllowedParamsModelAttributeMethodProcessor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
bindRequestParameters(org.springframework.web.bind.WebDataBinder binder,
org.springframework.web.context.request.NativeWebRequest request,
String[] allowedParams)
Extension point to bind the request to the target object.
|
protected Object |
createAttribute(String attributeName,
org.springframework.core.MethodParameter methodParam,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory,
org.springframework.web.context.request.NativeWebRequest request)
Extension point to create the model attribute if not found in the model.
|
protected Object |
createAttributeFromRequestValue(String sourceValue,
String attributeName,
org.springframework.core.MethodParameter methodParam,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory,
org.springframework.web.context.request.NativeWebRequest request)
Create a model attribute from a String request value (e.g.
|
protected String |
getRequestValueForAttribute(String attributeName,
org.springframework.web.context.request.NativeWebRequest request)
Obtain a value from the request that may be used to instantiate the
model attribute through type conversion from String to the target type.
|
protected Map<String,String> |
getUriTemplateVariables(org.springframework.web.context.request.NativeWebRequest request) |
void |
handleReturnValue(Object returnValue,
org.springframework.core.MethodParameter returnType,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest) |
protected boolean |
isBindExceptionRequired(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter methodParam)
Whether to raise a fatal bind exception on validation errors.
|
Object |
resolveArgument(org.springframework.core.MethodParameter parameter,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
Resolve the argument from the model or if not found instantiate it with
its default if it is available.
|
boolean |
supportsParameter(org.springframework.core.MethodParameter parameter) |
boolean |
supportsReturnType(org.springframework.core.MethodParameter parameter) |
protected void |
validateIfApplicable(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter methodParam)
Validate the model attribute if applicable.
|
public AllowedParamsModelAttributeMethodProcessor()
public boolean supportsReturnType(org.springframework.core.MethodParameter parameter)
supportsReturnType 在接口中 org.springframework.web.method.support.HandlerMethodReturnValueHandlerpublic void handleReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) throws Exception
handleReturnValue 在接口中 org.springframework.web.method.support.HandlerMethodReturnValueHandlerExceptionpublic boolean supportsParameter(org.springframework.core.MethodParameter parameter)
supportsParameter 在接口中 org.springframework.web.method.support.HandlerMethodArgumentResolverpublic final Object resolveArgument(org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.web.bind.support.WebDataBinderFactory binderFactory) throws Exception
@java.validation.Valid is present on the argument.resolveArgument 在接口中 org.springframework.web.method.support.HandlerMethodArgumentResolverorg.springframework.validation.BindException - if data binding and validation result in an error
and the next method parameter is not of type Errors.Exception - if WebDataBinder initialization fails.protected Object createAttribute(String attributeName, org.springframework.core.MethodParameter methodParam, org.springframework.web.bind.support.WebDataBinderFactory binderFactory, org.springframework.web.context.request.NativeWebRequest request) throws Exception
attributeName - the name of the attribute (never null)methodParam - the method parameterbinderFactory - for creating WebDataBinder instancerequest - the current requestnull)Exception - thrown on a type mismatch when trying to set a bean property.protected void bindRequestParameters(org.springframework.web.bind.WebDataBinder binder,
org.springframework.web.context.request.NativeWebRequest request,
String[] allowedParams)
binder - the data binder instance to use for the bindingrequest - the current requestallowedParams - 允许接受的参数数组protected void validateIfApplicable(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter methodParam)
The default implementation checks for @javax.validation.Valid,
Spring's Validated,
and custom annotations whose name starts with "Valid".
binder - the DataBinder to be usedmethodParam - the method parameterprotected boolean isBindExceptionRequired(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter methodParam)
binder - the data binder used to perform data bindingmethodParam - the method argumenttrue if the next method argument is not of type Errorsprotected String getRequestValueForAttribute(String attributeName, org.springframework.web.context.request.NativeWebRequest request)
The default implementation looks for the attribute name to match a URI variable first and then a request parameter.
attributeName - the model attribute namerequest - the current requestnull if noneprotected final Map<String,String> getUriTemplateVariables(org.springframework.web.context.request.NativeWebRequest request)
protected Object createAttributeFromRequestValue(String sourceValue, String attributeName, org.springframework.core.MethodParameter methodParam, org.springframework.web.bind.support.WebDataBinderFactory binderFactory, org.springframework.web.context.request.NativeWebRequest request) throws Exception
The default implementation converts only if there a registered
Converter that can perform the conversion.
sourceValue - the source value to create the model attribute fromattributeName - the name of the attribute (never null)methodParam - the method parameterbinderFactory - for creating WebDataBinder instancerequest - the current requestnull if no suitable conversion foundException - thrown on a type mismatch when trying to set a bean property.Copyright © 2017 Pivotal Software, Inc.. All rights reserved.