struts.xml action 默认方法和指定方法

发布时间 2023-06-06 13:17:36作者: zno2

https://struts.apache.org/docs/action-configuration.html#ActionConfiguration-ActionMethods

The default entry method to the handler class is defined by the Action interface.

Action interface
public interface Action {
    public String execute() throws Exception;
}

 Implementing the Action interface is optional. If Action is not implemented, the framework will use reflection to look for an execute method.

Sometimes, developers like to create more than one entry point to an Action. For example, in the case of a data-access Action, a developer might want separate entry-points for createretrieveupdate, and delete. A different entry point can be specified by the method attribute.

<action name="delete" class="example.CrudAction" method="delete">
    ...

 If there is no execute method and no other method specified in the configuration the framework will throw an exception.