Struts Development Guide workflow
The picture below is the workflow of Struts. We mentioned before, all requests are submitted to the ActionServlet.
ActionServlet is a FrontController that is a standard servlet, which forwards request to RequestProcessor,
Actionmapping is a subclass of ActionConfig, essentially a map of Struts-Config.xml, which can get all configuration information from it.
RequestProcessor Gets the appropriate actionforn and action from ActionMapping based on the submitted URL, such as * .do. Then correspond to the parameters of the Request to ActionForm, perform Form verification. If verification is called an action () method () method to perform an action, eventually returns ActionFoward.
ActionFoward is a packaging of a foward in mapping, corresponding to a URL
Actionform uses viewhelper mode and is a package for Form in HTML. It includes a validate method for verifying the effectiveness of the FORM data. ActionForm is a class that meets the JavaBean specification, all attributes should meet GET and SET. For some complex systems, DynaActionForm can also be used to construct a dynamic Form, which is generated by a prefabricated parameter. This makes a more flexible extension program.
ActionerRORS is a packaging for error messages, once an exception occurs in execution or form.validate, you can generate an actionerror and eventually add to ActionerRors. During the Form verification, if there is ERROR, the page will be re-directed to the input page, and the error is prompted.
Action is the REQUSESTHANDLER for performing business logic. Each Action only establishes an instance. Action is not a thread safe, so you should not access specific resources in the action. In general, the business delegate mode should be changed to access the business tier to unprepose.
Struts provides a variety of Action for selection. Ordinary Action can only perform a task by calling Execute, and DispatchAction can be performed according to the configuration parameters, not only enter the execute () function, which can perform a variety of tasks. Such as INSERT, UPDATE, etc. The LookUpdispatchaction can perform a function according to the name of the submitting form button.
We can go back to the examples just now, understand the Struts process.
Let's take a look at the EXAMPLE example of Struts:
Note: Example 2 is the Example program comes with Struts, which implements login, registration, and modify the function.
Struts Taglib is applied in the code, and the Validator plugin is used to verify the FORM.
But the code sets a bad example, which is written in an action of a lot of business logic.
Part of the code is as follows:
Logon.jsp
<% @ Page ContentType = "Text / HTML; Charset = UTF-8" Language = "Java"%> // Declaration Taglib <% @ Taglib URI = "/ Web-inf / struts-bean.tld" prefix = "bean "%> <% @ Taglib URI =" / Web-inf / struts-html.tld "prefix =" html "%> HTML: Submit value = "submit" /> td>
<