Beginner struts

xiaoxiao2021-03-06  131

All rights reserved as Shi Shixiang (Elpha (AT) MSN (Dot) .com

Contact: MSN: Ealpha (AT) MSN (Dot) .com

QQ: 9690501

===================================================

Learning Struts for a long time, but I still feel that my confused, especially the relationship between ActionServlet, action, and Actionform is difficult to figure out, and how Struts is running, it is also very confused.

Summary some experiences are provided to everyone, I am a place where beginners is inevitable. I hope everyone will correct it.

A separate action servlet is provided in the STRUTS framework. It actually acts as a controller role, responsible for processing browser requests, but do not perform any specific exercises, the specific operation is done in the subclass of the Action.

First, apply the Struts framework system, and must map with some URL-Pattern to the Action Servlet in the web application configuration file Web.xml. Such as

Web.xml

-------

Action

*. do

---------

The above code, you can modify * .do is other suffixes, such as * .asspx, the corresponding you want to modify your form action, such as

Modified to

Second, the action ( action ) has been mapped in Web.xml, and Action is a class of Struts framework. It sets each different Action subclass mapping via struts-config.xml.

The browser request is mapped to one such subclass in the struts-config.xml file, and the Action Servlet loads the configuration at runtime and assigns the request to the corresponding Action sub-class. Such as:

Struts-config.xml

...... ..

.......

The above code can see the path in the path ("/ WelcomeAction") maps to class Type ("strutstest.welcomeaction")

Third, the Actionform Bean browser with parameters, the user submits the HTML form, and the Struts framework puts the parameters in an org.apache.struts.Action.ActionFormBean. The role of the Actionform Bean can be obtained from the database to the form, or verify the form value in the form.

Fourth, the label library, the label library is used to support Actionform Beans, which can push data in the ActionForm Bean into the view (JSP). It can be provided by the user to determine the character display (international).

5. You can understand the jump URL after the Action operation is completed, and the Action returns an actionforward to tell Struts after processing. Such as:

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

New Post(0)