Struts MVC and simple processes

xiaoxiao2021-03-06  24

Today, I will stop it in the afternoon, it is really ◎ # ¥% ... ※ ×

, I have to read the book. Summarize some of the understanding of Struts about MVC. Struts tags and form submission process is organized.

Struts implements the Controler section, that is, the ActionServlet class, usually use Struts to hand over all .do requests to this class, this class is processed by that Action object according to the struts-config.xml configuration file. To make Struts's ActionServlet class, you should declare in Web.xml, initialize struts-config.xml mapping. DO request

Action

*. do

action org.apache.struts.Action.ActionServlet

config /web-inf/struts-config.xml

......

The view is a pile of JSP files that can be used with the label library provided by Struts. Model, to inherit the Actionform, and the FORM in the web page corresponds, the simple model is set / get and verify validate. Then hand it over to the action. I don't know if the action belongs to that section, it seems that it is not enough. This is still not understood. Release LoginAction requires struts-config.xml configuration: one example

Tomcat load process.

Use the label form:

Read the text from the Application.properties file, replace the corresponding label code with the "tab of the" HTML: Form> to find the corresponding form bean in the Session range, if there is such an instance, the property in the origan is mapped to Form In the input text box of the form. Not ignored.

submit Form:

Servlet / JSP container finds * .do's servlet-mapping: action in a web.xml file. Find the corresponding ActionServlet class in the servlet-name in the servlet element according to the settings in Struts-Config.xml, create the corresponding FORM object, pass the form data submitted by the customer to the FORM object, this object is saved within the session range if FORM has a Validate method, if the verification failed (here, the defense requirements such as format) VALIDATE method returns an ActionerRors object, contains an actionerror object ActionServlet from struts-config.xml to find the element, according to it The input property returns the form, if the form uses the tag, read the corresponding error message from Application.properties. (Refer to the above Action Element Example) Verification Successfully, the ActionError object returned by the Validate method does not contain any ActionError objects. ActionServlet finds the element that matches the Path property from Struts-Config.xml, finds the action instance in the type property in , creating one, contains an actionMApping object with the above element configuration information, then call LoginAction EXECUTE method. Operation in Execute, then find the corresponding sub-elements in based on the results, get an ActionForward object, and return to the ActionServlet. This step is to be coded by yourself. ActionServlet forwards the customer request to the page of the ActionForward object.

转载请注明原文地址:https://www.9cbs.com/read-66423.html

New Post(0)