STRUTS2 Summary---Implement action three ways (2)

Source: Internet
Author: User

Struts2 's core function is action, and for developers, using STRUTS2 is primarily about writing action, The action class typically implements the Com.opensymphony.xwork2.Action interface and implements the Execute () method in the interface.

The method is as follows:

Public String Execute () throws Exception

STRUTS2 does not require all of the action classes that are written to implement the action interface, or you can write a normal Java class as an action, as long as you implement a public method that returns a non-argument of type string:

Public String xxx ()

In actual development, the action class seldom implements the action interface directly, Usually inherited from the Com.opensymphony.xwork2.ActionSupport class, Actionsupport implements the action interface and some other optional interfaces, provides input validation, error information access, and internationalization support, choosing from Actionsupport Inheritance, you can simplify the definition of an action.

After you have developed the action, you need to configure the action to tell the STRUTS2 framework which action should be taken to handle the request for a URL.

1. Action Mapping:
The action map is the basic "unit of work" in the STRUTS2 framework, where the action map maps a request URL (that is, the name of the action) to an action class, which is used by the framework to determine how to handle a request when a request matches the name of an action.
Full attribute table for action element

Property

Whether you must

Description

Name

Is

The name of the action, used to match the URL

Class

Whether

The full class name of the action implementation class

Method

Whether

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.