SSH Framework Learning--Structs section (1)

Source: Internet
Author: User

Structs is responsible for the control layer in the SSH framework and is an open source framework based on the MVA development design pattern, which consists mainly of three parts:

1, the Form object Class (~form.java), inherits the Actionform class, is the data model.

2. The action Class (~action.java) used to process the request, inheriting the action class, for the controller.

3, structs configuration file (Structs-config.xml), the completion of the Actionform class and the Association of the Action class configuration.


Form Object Class (~form.java)

The class is used to hold parameters in the request form that inherit the Actionform class, where the attributes should match each parameter in the request.

The label for the <form-beans> in the corresponding profile file, which corresponds to the specific form class, is the label is <form-bean>, and the label includes the name and type two properties.

Exp:<form-bean name= "LoginForm" type= "Com.form.LoginForm" ></form-bean>

LoginForm is the name, type is the path.

Action class for processing requests (~action.java)

1, the class is used to handle the request of the specific operation class, inherit the action class, you need to override the action class in the Execute method:

Public Actionforward Execute (actionmapping mapping,actionform form, HttpServletRequest requst,httpservletresponse Response) throws Exception)

2, corresponding to the <action-mappings> tag in the configuration file, which is used to configure the request path (resource name), and the request path corresponding to the request processor.

3, corresponding to the specific action is the <action-mapping> tag sub-label <action>, its properties are Path,name, type.

Exp:<action path= "/loginaction" name= "LoginForm" type= "Com.action.LoginAction" ></action>

The configuration description asks the processor to be com.action.LoginAction (Control), and the request parameter is stored in the LoginForm form object (Model) that is configured in the <form-bean> tab.

4, <action> has a label <forward> label used when the request processing is completed after the turn, such as the results of the page display. <forward> includes the name and path properties, and path indicates the redirected page path.

SSH Framework Learning--Structs section (1)

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.