Struts 1-DispatchAction, dispatchaction
DispatchAction is a built-in universal distributor of struts 1.
Import org. apache. struts. actions. dispatchAction; public class UserAction extends DispatchAction {public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throwsException {// call the business logic operation // be sure to execute this sentence, or simply remove the execute () method from return super.exe cute ();} public ActionForward list (ActionMapping mapping, actionForm form, HttpServletRequest request, HttpServletResponse response) throwsException {// call the business logic operation return mapping. findForward ("list_success");} public ActionForward del (ActionMappingmapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {// call the return mapping operation of the business logic. findForward ("del_success");} public ActionForward add (ActionMappingmapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throwsException {// call the return mapping of the business logic operation. findForward ("add_success ");}}
The preceding Action has three business-related methods: list (), add (), and del (). After Struts transfers the request to this Action, the method to be executed is determined based on a parameter name. The parameter name is the same as the method name in the Action. This parameter needs to be configured in <action-mapping>, usually action or method
<Action name = "firstForm" path = "/user" parameter = "method" <! -- Distributor parameter --> type = "com. clf. struts. action. HelloAction"/>