问题描述:

I am new to Struts 1 and I am trying to educate myself via the official documentation provided by apache.org website.

The difference between ActionForm Beans and ActionsForm Classes is not completely clear to me.

I do understand the standards for creating a java bean. But I am a bit puzzled by the fact that the "ActionForm Classes" section lists principles to create "ActionForm Bean".

Why are these listed as two separate items? Shouldn't all Struts ActionForms be created as java beans? Could anyone please enlighten me with an explanation or some examples? Thank you!

Here is the information source:

2.3 ActionForm Beans

Note: While ActionForm beans often have properties that correspond to properties in your Model beans, the form beans themselves should be considered a Controller component. As such, they are able to transfer data between the Model and View layers.

source: http://struts.apache.org/development/1.x/userGuide/building_model.html

4.3 ActionForm Classes

An ActionForm represents an HTML form that the user interacts with over one or more pages. You will provide properties to hold the state of the form with getters and setters to access them. ActionForms can be stored in either the session (default) or request scope. If they're in the session it's important to implement the form's reset method to initialize the form before each use. The framework sets the ActionForm's properties from the request parameters and sends the validated form to the appropriate Action's execute method.

When you code your ActionForm beans, keep the following principles in mind:

. . .

source: http://struts.apache.org/development/1.x/userGuide/building_controller.html

相关阅读:
Top