Advertise on ITWeb         Sun, 22 Oct, 23:00:32 PM

Industry Insight

A look at MVC frameworks

MVC frameworks provide limited functionality when compared to ZK, Echo and other Java Web frameworks.

In the previous Industry Insight in this series, I looked at ZK and Echo and began looking at component-based frameworks. In this, the third article, I will consider MVC frameworks.

General description:

These frameworks all work in essentially the same way, by implementing the popular Model, View and Controller pattern. The front-end typically uses JSP, so the separation between presentation and logic depends on a disciplined development approach. MVC frameworks tend to focus on binding to the front-end, performing validation, and resolving request views and controllers.

They also tend to rely heavily on configuration, with the controllers typically implemented as Pojos and the views being simple JSPs with custom tag libraries, although recently a trend has developed to use convention over configuration.

These frameworks provide limited functionality when compared to the frameworks looked at in the previous two sections; in fact some of the frameworks already discussed include a full MVC in addition to the rest of their functionality.


Spring MVC, Struts 2


* Uses a well-known approach.
* Flexible.
* Plumbing code usually configured with XML or annotations, or more recently by coding by convention.
* Widely used in production systems.


* Does not provide elaborate component libraries.
* All Ajax done by JavaScript or third-party libraries.
* Requires much configuration.
* Limited functionality makes these frameworks the first step above plain JSPs and servlets.

When to use these frameworks:

* For fairly simple front-end requirements.
* If you have an existing system and want to add the binding and flow control functionality that MVC provides.
* If already using Spring throughout your system, using Spring MVC could be a natural choice.

Spring MVC

This is possibly the most widely used MVC framework, largely due to the success of the Spring framework with which it comes bundled. Like Spring, this MVC is non-intrusive, with the configuration located in Spring context files. Alternatively, annotations can be used, and from 2.5 many coding convention-based configurations have been introduced.

Spring into action

If already using Spring throughout your system, using Spring MVC could be a natural choice.

The framework provides simple but powerful URL mapping mechanisms to map requests to controllers. The controllers can extend Spring controller classes, or be configured as Pojos. For the front-end, the framework uses JSP with a Spring MVC tag library for form binding, but a variety of views can be used such as Freemarker, Velocity, or JasperReports.

Since this MVC is bundled with Spring, it can form part of a complete application similar to Seam but without requiring a J2EE container. In the tradition of Spring, it integrates with many different technologies including other MVCs (Struts), various view technologies, Spring Security, and any service layer that Spring can be integrated with.


* Customisable, powerful binding and validation.
* Non-intrusive.
* Customisable locale and theme resolution.
* Powerful configuration capabilities using Spring application contexts.
* Part of the Spring framework.


* Works best with JSP as the front-end.
* Provides a simple MVC and not much else.
* Requires a lot of configuration.

In the next, final Industry Insight, I will look at other frameworks and factors to consider when choosing a Java Web framework.

* Andre van der Schyff is a senior developer at DVT.

Our comments policy does not allow anonymous postings. Read the policy here




Sponsors Message