Struts2 Action


Action class is where all the action happens in framework. Framework look for the request and matches it to available Actions and if it finds any it determine how to process the request.

Action Name

In web application, Action name attribute is matched to find the exact resource to execute for given request.
Example: http://localhost:8080/strutsapp/
Here ‘strutsapp’ is Context Root which will be different for different application, hello is the action name which framework will look for in application for mapping.

Action Mapping

The action mapping specifies a class, set of result types, a set of exception handlers, and an interceptor stack. Only the name attribute is required. The other attributes can also be provided at package scope.

<action name="Login" class="com.login">
  <result name="success">/success.jsp</result>
  <result name="input">/login.jsp</result>

Here “Login” is the action name. when framework finds any request with this action name e.g: ‘localhost:8080/root/’. Framework will know that given request is for above action mapping and invoke the class ‘’ and after processing the class it will forward the request to either ‘success.jsp’ or ‘login.jsp’ depending on the return type from action.

By | 2012-04-28T05:21:28+00:00 April 28th, 2012|Uncategorized|0 Comments

About the Author:

Leave A Comment