spring-framework / org.springframework.web.servlet.mvc.method.annotation / ServletModelAttributeMethodProcessor

ServletModelAttributeMethodProcessor

open class ServletModelAttributeMethodProcessor : ModelAttributeMethodProcessor

A Servlet-specific ModelAttributeMethodProcessor that applies data binding through a WebDataBinder of type ServletRequestDataBinder.

Also adds a fall-back strategy to instantiate the model attribute from a URI template variable or from a request parameter if the name matches the model attribute name and there is an appropriate type conversion strategy.

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
3.1

Constructors

<init>

ServletModelAttributeMethodProcessor(annotationNotRequired: Boolean)

Class constructor.

Inherited Functions

handleReturnValue

open fun handleReturnValue(returnValue: Any, returnType: MethodParameter, mavContainer: ModelAndViewContainer, webRequest: NativeWebRequest): Unit

Add non-null return values to the ModelAndViewContainer.

resolveArgument

fun resolveArgument(parameter: MethodParameter, mavContainer: ModelAndViewContainer, webRequest: NativeWebRequest, binderFactory: WebDataBinderFactory): Any

Resolve the argument from the model or if not found instantiate it with its default if it is available. The model attribute is then populated with request values via data binding and optionally validated if @java.validation.Valid is present on the argument.

supportsParameter

open fun supportsParameter(parameter: MethodParameter): Boolean

Returns true if the parameter is annotated with ModelAttribute or, if in default resolution mode, for any method parameter that is not a simple type.

supportsReturnType

open fun supportsReturnType(returnType: MethodParameter): Boolean

Return true if there is a method-level @ModelAttribute or, in default resolution mode, for any return value type that is not a simple type.