• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are the Model classes?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between ModelAttribute, ModelAndView, ModelMap, Model in spring?



Thank you.
Shravani.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Model is an interface. ModelMap is an implementation of the Model interface. ModelAndView is a Model and also has a String to store the view string. ModelAttribute is an attribute in a Model to get it out. ModelAttribute is an Annotation.

Basically when you have data in code and you want to make that data available to the rendering of your jsp page, you need to put that data somewhere so that it is available. That is what a Model is for. To hold that data you retrieved in your code. It is just a glorified map.

So example, I have a form with a backing object with data. The form has three drop downs that I also need data to fill the drop downs. That is 4 different objects. 3 Lists for the drop downs and one object for the form backing object.
If my code gets all this data, I put them into the Model's Map and now I can use them on my jsp page.

Mark
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Model is an interface. ModelMap is an implementation of the Model interface. ModelAndView is a Model and also has a String to store the view string. ModelAttribute is an attribute in a Model to get it out. ModelAttribute is an Annotation.

Basically when you have data in code and you want to make that data available to the rendering of your jsp page, you need to put that data somewhere so that it is available. That is what a Model is for. To hold that data you retrieved in your code. It is just a glorified map.

So example, I have a form with a backing object with data. The form has three drop downs that I also need data to fill the drop downs. That is 4 different objects. 3 Lists for the drop downs and one object for the form backing object.
If my code gets all this data, I put them into the Model's Map and now I can use them on my jsp page.

Mark



Dear Mark,

I am not fully convinced by your answer.
Can you please elaborate more.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic