Skip to main content
Commonmark migration
Source Link

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstract away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

 

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstract away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

 

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstract away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Modelorg.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstractionabstract away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMaporg.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Modelorg.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMaporg.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstraction away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstract away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

added 47 characters in body
Source Link
Bogdan
  • 3.7k
  • 13
  • 13

Is the Model in Spring MVC the same of MVC pattern?

NoIf you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstraction away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

No, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstraction away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Is the Model in Spring MVC the same of MVC pattern?

If you mean org.springframework.ui.Model, then no, it isn't.

In MVC, the Model is where your business lives. The Model in MVC manages the data, and domain rules of the application.

In Spring, the Model you are referring to is a holder for data that the view displays. It's basically a glorified Map underneath.

A view is responsible for rendering the model. The way views access the model data isn't the same across all views supported by Spring (JSP, FreeMarker, Portlets, etc) so you need a generic way to expose that data to any view, to abstraction away the view technology.

Before Spring 2.5.1 you sent this data as a Map (Spring has a org.springframework.ui.ModelMap with various helper methods on it... but still a Map) then the org.springframework.ui.Model interface was added which is a more semantic alternative to the same thing (it has a org.springframework.ui.ExtendedModelMap implementation which at the same time is a child of ModelMap).

From the ModelMap documentation (emphasis mine):

Implementation of {@link java.util.Map} for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for both Servlet and Portlet MVC, but is not tied to either of those. Check out the {@link Model} interface for a Java-5-based interface variant that serves the same purpose.

So, this Spring Model interface is just a container of key-value attributes for the View to render. It's called Model most likely because this is a MVC framework with Controllers and Views and Models (i.e. MVC stands for Model View Controller, not Map View Controller - so people relate better to that naming).

Source Link
Bogdan
  • 3.7k
  • 13
  • 13
Loading