Struts2.0 and Model-View-Controller (MVC) Design Pattern
Previous Home Next


The Struts 2 framework follows the well-established Model-View-Controller design pattern. The Model represent the data and state,view represent the presentation logic and controller represent the work flow of the struts 2.0 framework.The MVC design pattern identifies three distinct concerns: model, view, and controller.In Struts 2, these are implemented by the action, result, and FilterDispatcher, respectively.

Struts2.0 Action Component- Actions component implemented by the Struts 2 Action interface. But what exactly is the model .The model is the internal state of the application. This state is composed of both the data model and the business logic.

package org.r4r;
public class MyAction {
	private String name,password;
	public String execute(){
		return "success";
	public String getName() {
		return name;
	public void setName(String name) { = name;

 Struts2.0 Result Component- The Result component is the presentation component of the MVC pattern. the result returns the page to the web browser. This page is the user interface these are commonly JSP pages, Velocity templates, or some other presentation-layer technology.


<%@taglib uri="/struts-tags" prefix="s"%>

<s:form action="hello">
<s:textfield name="name" label="Name"/>
<s:submit value="Submit"/>

 Struts2.0 FilterDispatcher Component-The role of the controller is played by the Struts 2 FilterDispatcher. The FilterDispatcher class controlling the over all work flow in the struts2.0 framework..


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 

Previous Home Next