Request Mapping methods - supported method arguments

The following are some of the types of arguments that are supported in Controller methods with Request Mapping:

Argument Type/Annotation

Use

java.util.Map / org.springframework.ui.Model / org.springframework.ui.ModelMap

Acts as the model (MVC) that will be the container for values that are exposed to the view.

Command or form objects

Used to bind request parameters to beans. Support for validation as well.

org.springframework.validation.Errors / org.springframework.validation.BindingResult

Result of validating the command or form object (the form object should be the immediately preceding method argument).

@PreDestroy

On any spring bean, a pre-destroy method can be provided using the @PreDestroy annotation. This method is called just before a bean is removed from the container. It can be used to release any resources that are held by the bean.

@RequestParam

The annotation to access specific HTTP request parameters.

@RequestHeader

The annotation to access specific HTTP request headers.

@SessionAttribute

The annotation to access attributes from HTTP Session.

@RequestAttribute

The annotation to access specific HTTP request attributes.

@PathVariable

The annotation allows access to variables from the URI template. /owner/{ownerId}. We will look at this in depth when we discuss microservices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset