From the course: Complete Guide to Spring MVC
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Model - Spring Tutorial
From the course: Complete Guide to Spring MVC
Model
- [Instructor] Model. What is a model attribute? A model attribute is like a container that holds data that you want to share between the controller and the view. So think the HTML pages rendered with Thymeleaf that we had earlier. It allows you to bind HTTP request data like form inputs to Java objects. And then it also allows you to pre-populate objects for use in your views. Again, it's like that item. Think of a suitcase or a container as I mentioned for carrying data around in a web application. For binding request parameters to Java objects, let's look at this example. Spring automatically maps request parameters, so like I mentioned, like form fields to the fields of a Java object. So in this example, if the request includes parameters like name equals John and email equals john@example.com, Spring will populate a user object with these values, binding the request parameters to the Java objects in your form fields. Model attribute can also be used at the method level to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Declaration overview4m 32s
-
(Locked)
Declaration: AOP proxies6m 23s
-
(Locked)
Mapping requests overview5m 19s
-
Mapping requests: URI patterns5m 50s
-
(Locked)
Mapping requests: Consumable media types4m
-
(Locked)
Mapping requests: Producible media types3m 53s
-
(Locked)
Handler methods overview3m 9s
-
(Locked)
Handler methods: Method arguments2m 54s
-
(Locked)
Handler methods: Return values5m 2s
-
(Locked)
Handler methods: Type conversion4m 47s
-
(Locked)
Model3m 16s
-
(Locked)
@InitBinder overview7m 46s
-
(Locked)
Validation3m 33s
-
(Locked)
Exceptions overview4m 39s
-
(Locked)
Exceptions: Method arguments3m 56s
-
(Locked)
Exceptions: Return values6m 47s
-
(Locked)
Controller advice10m 32s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-