Action in struts 2 by using POJO class

As we discussed in earlier tutorials that any POJO class can be used as action class in struts 2. Only requirement is that it must have one no-argument method that returns a String or Result object. The execute() method is used by default if no-argument method is not there. Example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> … Read more

Action in struts 2

Actions: Actions are the core element of struts 2. Actions contain the necessary processing logic to complete the request from the user. Actions are also used to interact with the other layers like view layer. How to create Action in struts 2? In struts 2 an action can be created by following ways: Action in … Read more

Struts 2 Configuration Files

Struts.xml file: The struts.xml is the core configuration file for struts framework. The struts.xml is used to initialize the resources like Interceptors, Action classes and Results. Syntax: <struts>   <package name="packageName" extends="struts-default">   <action name="actionName" class="actionClass" method="methodName"> <result name="success">/HelloWorld.jsp</result> </action>   //more actions.   </package>   //more packages.   </struts><struts> <package name="packageName" extends="struts-default"> <action name="actionName" … Read more

Struts 2 Architecture

Sturts 2 MVC framework contains the following core components: Actions. Interceptors. Value Stack / OGNL Result types Diagram: Struts 2 request life cycle: When a request comes web container maps the request in the web.xml and calls the controller (FilterDispatcher). FilterDispatcher calls the ActionMapper to find an Action to be invoked. FilterDispatcher calls the ActionProxy. … Read more