Structs is responsible for the control layer in the SSH framework and is an open source framework based on the MVA development design pattern, which consists mainly of three parts:
1, the Form object Class (~form.java), inherits the Actionform class, is the data model.
2. The action Class (~action.java) used to process the request, inheriting the action class, for the controller.
3, structs configuration file (Structs-config.xml), the completion of the Actionform class and the Association of the Action class configuration.
Form Object Class (~form.java)
The class is used to hold parameters in the request form that inherit the Actionform class, where the attributes should match each parameter in the request.
The label for the <form-beans> in the corresponding profile file, which corresponds to the specific form class, is the label is <form-bean>, and the label includes the name and type two properties.
Exp:<form-bean name= "LoginForm" type= "Com.form.LoginForm" ></form-bean>
LoginForm is the name, type is the path.
Action class for processing requests (~action.java)
1, the class is used to handle the request of the specific operation class, inherit the action class, you need to override the action class in the Execute method:
Public Actionforward Execute (actionmapping mapping,actionform form, HttpServletRequest requst,httpservletresponse Response) throws Exception)
2, corresponding to the <action-mappings> tag in the configuration file, which is used to configure the request path (resource name), and the request path corresponding to the request processor.
3, corresponding to the specific action is the <action-mapping> tag sub-label <action>, its properties are Path,name, type.
Exp:<action path= "/loginaction" name= "LoginForm" type= "Com.action.LoginAction" ></action>
The configuration description asks the processor to be com.action.LoginAction (Control), and the request parameter is stored in the LoginForm form object (Model) that is configured in the <form-bean> tab.
4, <action> has a label <forward> label used when the request processing is completed after the turn, such as the results of the page display. <forward> includes the name and path properties, and path indicates the redirected page path.
SSH Framework Learning--Structs section (1)