Learn to use Dispatchaction

xiaoxiao2021-03-06  20

DispatCHACTION Inherits from the Action class, it is an abstract class that encapsulates some basic methods to solve the ability to use an action to handle multiple operations, which is the biggest use of Dispatchction, it can help us with an Action class, package The operation method saves the number of classes, and it also reduces the difficulties of later maintenance.

There are several ways to include several methods in Dispatchaction:

Protected actionforward dispatchMethodprotected java.lang.reflect.Method getMethodprotected java.lang.string getmethodname

Dispatchaction is slightly different in the configuration of the standard Action, that is, in the Action configuration, this property will guide Dispatchction to find the corresponding method, such as this configuration:

attribute value of parameter It can be arbitrarily, as long as you remember to unify the parameter. For example, I wrote a similar Action, which inherits from the Dispatchaction class, contains three operation methods, add (), update (), delete (). When I want to call this Action update operation, the submitted URL should be like this: http: // localhost: 8080 / myapp / saveSubscription.do? Method = update is so simple, but very good, our programmer, development I feel a lot of code, at least three types of files become a class, and it is convenient to feel when it is maintained in the later maintenance. It should be noted that the Method parameter cannot be empty when calling the dispatchaction. If empty, DispatchAction will call the unspecified method and throw an exception.

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

New Post(0)