91-9990449935 0120-4256464 |
Struts 2 Zero Configuration by conventionWe 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.jsp2) Create the action classThe 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.java3) Create view componentsThe 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
Next TopicStruts2 Annotations Example
|