Struts 2 Zero Configuration by convention
We can create struts 2 application without the configuration file struts.xml. There are two ways to create zero configuration file:
The steps to create zero configuration file using convention is as follows:
Example to create zero configuration file by convention.
In this example, we are creating 4 pages :
1) Create index.jsp for input (optional)
This jsp page creates a form using struts UI tags. It receives name and password from the user.index.jsp
2) Create the action class
The action class name must be suffixed by action following the request name or it must implement the Action interface (or extend ActionSupport). Suppose that request name is login, action class name should be LoginAction if you don't want to implement Action interface.
The action class must be located inside the action or actions or struts or struts2 package.LoginAction.java
3) Create view components
The view components must be located inside the WEB-INF/content folder.
The view components must be named with request name - (hyphen) string returned by action class. Suppose that request name is login and string returned by action class is success and error, file name must be login-success.jsp and login-error.jsp.login-success.jsp login-error.jsp