RequestMapping methods – supported method arguments

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

Argument Type/Annotation

Use

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

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

Command or form objects

This is used to bind request parameters to beans. There is support for validation as well.

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

This is the 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

This is the annotation to access specific HTTP request parameters.

@RequestHeader

This is the annotation to access specific HTTP request headers.

@SessionAttribute

This is the annotation to access attributes from the HTTP session.

@RequestAttribute

This is 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 detail 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