Struts 1-DispatchAction, dispatchaction

Source: Internet
Author: User

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"/>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.