ActionMapping

xiaoxiao2021-03-05  25

In Struts, the ActionServlet is just assignment of the task, which is executed by requesting the assignment task to other objects, and the assigned basis is the content set by the requested URI and Struts-Config.xml . Used to describe a set of actionMApping objects, each volume label corresponds to an actionMApping object, when the client is requested to the ActionServlet, the ActionServlet is set according to its URI and The Path property View the corresponding actionMApping object, the ActionMapping object tells the ActionServlet which Action object (using the type attribute setting in the volume mark), and the ActionServlet is handed over to the Action object. For example, if is set as follows:

Code: .... . ...

When the requested URL is http: // localhost: 8080 / hellostruts / login.do, ActionServlet uses / login to find the actionMapping object set to login, the ActionMapping object tells ActionServlet To use Onlyfun.caterpillar.loginAction, Then, the ActionServlet will call the LoginAction's Execute () method, and pass the ActionMapping object as a parameter to it. The ActionServlet actually handed the work to the Action object, but the operation of the Action object must provide some parameters to describe the details of the work, such as using which ActionForm, Forward object lookup, the page object when the error occurs, Struts Package this information package In ActionMapping and transmit it to the Action object as a parameter so that the Action can be obtained from an actionMApping when the Action needs to be related. What if the client requests do not defined an actionMApping? Struts will throw 404 Invalid Path, you can write anonymous actionmapping to provide your own error message:

It is a request

URL

Yes

Http: // localhost: 8080 / hellostruts / login.do

,

ACTIONSERVLET

Will be used

/ Login

Come to find out

Path

set as

Login

of

ActionMapping

Object, this

ActionMapping

Object information

ACTIONSERVLET

need to use

ONLYFun.caterpillar.loginaction

,then

ACTIONSERVLET

Will call

Loginaction

EXECUTE ()

Method, and will

ActionMapping

The object is passed as a parameter to it.

ACTIONSERVLET

In fact, will be given

Action

Object, however,

Action

The operation of the object must provide some parameters to describe the details of the work, such as which one to use

Actionform

,

Forward

Object search, page object when the error occurs, etc.

Struts

Package this information

ActionMapping

In the middle, and transmit it as a parameter to

Action

Object, so that

Action

Can be from

ActionMapping

Among it.

For unfained

ActionMapping

What if the client requests?

Struts

Be thrown out

404 Invalid Path

Message, you can write anonymous

ActionMapping

To provide your own error message:

Code: name = "error" unknown = "true" Forward = "/ Pages / Error.jsp" />

in case

ACTIONSERVLET

Nothing to receive

Action

Request, will be charged

ActionMapping

Treatment.

in

Struts

in,

ActionMapping

Inheritance

ActionConfig

Most of the attribute definitions are actually

ActionConfig

Completed, but

ActionMapping

Still existing, depending on the line

API

Description, inheritance is based on the public categories used by the existing application.

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

New Post(0)