(Struts Framework Architecture)
Keyword
Struts, Framework, Architecture, Componennt, MVC
Prior knowledge at study start Struts ago, knowledge of the following points need to be know: Model - View - Control of the software architecture model, JSP / Servlet layer of web applications, J2EE architecture. If the tag type of customer (Customer TagLib) know there may be easier to understand Struts itself TagLib.

Outlined in this paper to explain the concept of what is on struts framework, the framework of its structure, components, structures and explain easy configuration. For its application please refer to the back of "struts installation and application" and "struts and practical case studies."
The article includes the following four major parts:
1, Framework brief introduction of the concept and system (Framework Conception and Architecture)
Two, Struts concepts and architecture (Struts Conception and Architecture)
Three, Struts working principle and components (Struts Componennts)
Four, Struts configuration file brief introduction (Struts Deployment Description)

1, Framework has always been our concept that struts is a web framework. Let me first take a look at what you are Framework. (I want to use "framework" to the translation framework, but then found more and more less than ideal and perfect, so on the direct use of the word Framework)
Framework concept was not very new, and accompanied by the development of software development, software development in multi-storey projects, reusable and easy to expand, and are well-tested software components, more and more popular for people. This means that people can be plenty of time to analyze, build business logic on the application, rather than complicated code works. Then people will question the same type of solution for abstract, taken as a application framework. This is what we call the Framework.
Framework of the system provides a clear set of mechanisms to allow developers to easily expand and control development on the entire framework structure. Usually, framework structure has a "command and control" component ( "command and control" component) - Framework Factory and Manager.

Photos (2): Framework system

Based response to the request (Request-Response) model of the application framework, essentially have the following logical structure of some performance.
(1) Controller (Controller) - control the entire framework of the coordination of the various components.
(2) Business Logic Tier (Business Logic) - This is the desired framework to solve the key problem. Framwork of course, itself, here is just enough to mention the concept and some basic components of the Service, the real implementation with the customer's business logic integration, but also required the developer to expand again in the framework.
(3) the data logic layer (Data Logic) - the vast majority of applications are related to data exchange required, this level of data mainly includes logic and data access interface. Logic for data, if you know Data Modeling (Data Modeling) probably very easy to understand.

Below to enter the U.S. on the subject - Struts structure

Two, Struts concepts and architecture
Struts has a group of mutual cooperation among the categories (components), Serlvet as well as the composition of jsp tag lib. Struts-based web application framework JSP Model2 basically in line with the design standards, it can be said MVC design patterns are a type of Change. According to the description on the face of framework, we are very easy to understand why Struts is a web framwork, and not just some combination of Tag Library. But Struts also contains a wealth of tag libraries and independent of the framework for utility-type work.
Struts has its own controller (Controller), at the same time integrating a number of other technologies to achieve model layer (Model) and the view layer (View). In the model layer, Struts can easily with a combination of data access technologies, including EJB, JDBC and Object Relation Bridge. In the view layer, Struts can with JSP, Velocity Templates, XSL and so on those that want to combine layer components.

2.1 Struts with Web App relationship

Now that struts called web framework, so its definitely the main web-based application development layer. In accordance with the J2EE Architecture standards, struts should be and jsp / servlet, as exists in the web container level. Such as picture (3) shown in picture (3): Struts and the relationship between WebApp

2.2 Struts architecture Say our MVC model struts framework are the embodiment of the following from us separately from the model, view, take a look at the struts control architecture (Architecture). Photos (4) shows the architecture of the struts framework to respond to customer requests, the various parts of the principle of job.
Photos (4): Struts Architecture

2.2.1 From the point of view (View)
Mainly by the JSP set up, struts itself contains a set of scalable custom tag library (TagLib), can simplify the process of creating the user interface. Currently include: Bean Tags, HTML Tags, Logic Tags, Nested Tags, Template Tags that some Taglib. Related to their struts detailed information please refer to user manual
2.2.2 From the perspective of the model (Model)
Model is mainly express the status of a system (sometimes to change the system state is also the business logic operation is also divided into the model). In Struts, the system status mainly reflected ActiomForm Bean, under normal circumstances, these non-persistent status. If necessary these status into persistent data storage, Struts itself provides Utitle package, it will be convenient with the database operations
2.2.3 From the perspective of the controller (Controller)
Struts framework at Medium, Controller mainly ActionServlet, but the business logic of the operation was mainly by the Action, ActionMapping, ActionForward that some components of the coordination of finish (this may be some components, it should be divided to model a business logic). One of, Action played a real business logic implementation, while ActionMapping and ActionForward is designated a different business logic or operation of the direction of flow.

2.3 Struts basic struts around the entire package has 15 packs, 200 near the composition of the class, but also to expand the quantity. In this we are unable to introduce only briefly outlined some of the main brief. The table below shows the current struts api some basic package, including action, actions, config, util, taglib, validator. Photos (5) while showing some components of the relationship between the packet. Action is one of the core of the struts framework
org.apache.struts.action
Basically, the struts framework to control the entire operation of the core categories, components in this package, such as our above-mentioned controller ActionServlet. Has Action, ActionForm, ActionMapping and so on. struts1.1 than DynaActionForm category of more than 1.0. An increase of the dynamic expansion of generating function FormBean
org.apache.struts.actions
This package is the main role is to provide the client http request and deal with business logic between the specific adapter conversion, and 1.0 versions of some dynamic additions and deletions FromBean class, but also struts1.1 been Action Pack DynaActionForm components replace
org.apache.struts.config
Provide configuration file struts-config.xml mapping elements. This is also the new features sturts1.1
org.apache.struts.util
Strtuts in order to better support the application of web application, a more common decency Services support, such as Connection Pool and the Message Source. For more information please refer to http://jakarta.apache.org/struts/api/org/apache/struts/util/package-summary.html
org.apache.struts.taglib
This is not a package, but customers are a collection of category tags. Including the following Bean Tags, HTML Tags, Logic Tags, Nested Tags, Template Tags that some used to build the user interface category tag.
org.apache.struts.validator
Struts1.1 framework added validator framework, for the dynamic configuration from a form of authentication. For more information please see http://home.earthlink.net/ ~ dwinterfeldt /

Three, Struts framework of the working principle and components for Struts how to control, handle customer requests, let us through the struts of the four core components to introduce details. This is some components: ActionServlet. Action Classes, Action Mapping (here including the ActionForward), ActionFrom Bean.
3.1 Struts ActionServlet
Inherited from the ActionServlet Class javax.servlet.http.HttpServlet, the Struts framework in the role of loss of control, see above "Struts system map." ActionServlet controller is mainly responsible for the HTTP client request information of the assembly, in accordance with the specified configuration file description, forward to the appropriate processor. (At Struts1.1 added org.apache.struts.action.Action.RequestProcessor category will deal with requests for the function separated from the controller function.
Servelt in accordance with the standards, all of a Servlet in web configuration file must be (web.xml) statement. Same, ActoinServlet must be at Web Application configuration file (web.xml) described, the configuration information, the latter will introduce.

When users submit a request to the server-side when in fact information is first sent to the controller ActionServlet, once the controller received the request, the request will be handed over to some auxiliary information Chuan category (help classes) treatment. These helper class know how to deal with requests for information by the corresponding operations. In Struts, this helper class is org.apache.struts.action.Action. Developers usually need to have their own inheritance Aciton categories, in order to achieve their own examples of Action.

3.2 Struts Action Classes
The role of a Class Action, as customers request action and business logic of a deal between the adapter (Adaptor), and its function is to separate the request with the business logic. Such separation, the client requests and Action category can have multiple point-to-point between the mapping. Class Action and usually also provide other support functions, such as: authentication (authorization), log (logging) and data validation (validation).
Action is the most commonly used in execute () method. (Note that previous methods perform at struts1.1 already no longer supported), have an execute () method, please refer to apidoc, not in this note.
When the Controller Receive customer request when the request to an Action instance of transfer, if this instance does not exist, the controller will first create, then will call the Action instance execute () method. Struts Framework for the application systems in each category Action only creates an instance. Since all users use this an example of you so you must determine the type of Action to run in a multi-threaded environment. The following diagram shows an execute () method of how to visit:

Photos (6): Action instances execute () method

Note that customers own Action subclass inheritance, we must rewrite the execute () method, because Class Action by default are the return null.

3.3 Struts Action Mapping
As mentioned above, a client request is how the controller forward and deal with, but controller How do I know what kind of information forward to the Class Action What does? This requires some action and request information corresponding to the mapping configuration instructions. In the struts, which configuration mapping information are stored in a particular XML document (such as struts-config.xml).
These configuration information at system start time was read into the memory, struts framework for use during operation. In memory, each element with org.apache.struts.action.ActionMapping <Action> an instance of the corresponding category. The following table shows a landing on the configuration mapping.

Above configuration, said: When can / logonAction.do (here the assumption that the controller configuration mapped to *. do) to submit requests for information, the controller will deal with information com.test.LogonAction commissioned. Call LogonAction instance execute () method. Mapping at the same time, examples and the corresponding LogonForm Bean incoming information. One of name = LogonForm, the use of form-bean element declaration ActionForm Bean. The relevant form-bean declaration is as follows show.

Elements <forward> said Action instance when execute () method of running or completed, the controller will respond according to Mapping information can be transferred to the appropriate place. Reality such as the above, if the client successfully landing, then calls welcome forward, the successful return to the information / welcome.jsp page. You at the execute () method can be used at the end of the following examples of code and back welcome forward. Of course, you must welcome forward the action element in the definition of property, as stated above it.

Say at this a little about the concept of global-forwards. Its in the configuration file to describe the entire application system can use the ActionForward, rather than just a specific Action.

3.4 Struts ActionForm Bean
At the top on the ActionServlet, Action Classes and Action Mapping, we have referred to the concept of the ActionForm Bean. An application system for message transfer (or transfer status) of non-persistent data storage, are responsible by the ActionForm Bean maintained.
ActionForm the main function of the operation of Action is to provide customers with mapping form data (if the client specified circumstances, including data validation). Action is responsible for maintaining the status system data, and the Action is responsible for business logic in accordance with the needs of status of data changes at the system state after the change, ActionForm automatically write-back of new data and to maintain status.
Note: At struts1.1 Medium, ActionForm validation features, gradually being stripped out (of course can still use). Validator framework used throughout the application of form data validation system for unified management. Trust information please refer to: http://home.earthlink.net/ ~ dwinterfeldt
At ActionForm use, Struts to promote the use of the value object (Value Object). This will customers or developers, with the status of data object status can more clearly understand and use.
For each client request, Struts framework deal at a time when ActionForm, it normally takes some experience of the following steps:
(1) Inspection Action mapping to determine the Action has been configured on the ActionForm mapping (2) property under the name, search form bean configuration information (3) Inspection Action of formbean range of uses identified in this context, does it have there is an example of this form bean.
(4) If the current scope, already exists for this form bean instance, but on the current request is the same type, then on the reuse.
(5) otherwise, on the re-build a form bean instance (6) form bean's reset () method call prepare (7) call the corresponding setter method of property status assignment (8) If the property validatede set to true North , then call the form bean's validate () method.
Note: Class ActionFrom directly inherited from the reset () and validate () method, and what treatment can not function, so there is a need to re-cover their own.
If validate () method does not return any error, the controller will ActionForm as a parameter to the Action instance execute () method and implement.

There is the need to refer to the relevant org.apache.struts.action.DynaActionForm. This is struts1.1 new features. Their inherited from ActionForm, at an earlier version of struts, we must man-made structure ActionFrom specific sub-category, but the use of DynaActionForm, property can be set based on the creation of dynamically from bean. On its detailed information, please refer to

Four, Struts other components
Struts framework itself provides a lot of expandable components or sub framework, to facilitate the development of personnel in its framework to build web layer on applications. Such as upload, collections, logging and so on. Let us look at two more important components: validationg framework and struts taglib. Please refer to other components on the Struts user manual (http://jakarta.apache.org/struts/userGuide).
Stuts1.0 at some very good concepts and components, such as benaUtils, Collections and so on, was later absorbed Jakarta Commons project team and independent Department struts framework. Struts but still need to rely on these components to get it to work.
4.1 Validation Framework for Struts
At struts1.1, the new validation framework. Increased the submitted form data validation. Originally required at ActionFrom Bean's validate () for authentication through the configuration file to verify the description.
On its detailed information, please refer to http://home.earthlink.net/ ~ dwinterfeldt. Personal recommendations for small applications can use this configuration mode, but the application of the system has substantial web application layer forms the system and business needs change in relatively large, use the validation framework will add to the possible development of the difficulty of system maintenance difficult. Validation framework can learn from the Javascript Validator Tag.

4.2 Struts TagLib
struts provides a set of scalable custom tag library (TagLib), can simplify the process of creating the user interface. Currently include: Bean Tags, HTML Tags, Logic Tags, Nested Tags, Template Tags that some Taglib. Struts Taglib on the structure and use, can refer to the front on the introduction of Cutomer Tag Lib, the play details, please refer to

4.3 BeanUtils
The full name of this component are Bean Introspection Utilites. Jakarta Commons are belong to the project team. The main is to help build a JavaBean property of the operation (getter, setter), has provided a dynamic definition of and access to the bean property. For more information, please refer to.
http://jakarta.apache.org/commons/beanutils.html
If you have very much interested in this area, you can refer to some of the java reflection (Reflectio) information.

4.4 Collections
This component is to provide a number of collection or list of objects, at the original java collections framework based on the expansion. Detailed information please refer to:
http://jakarta.apache.org/commons/collections.html and
http://cvs.apache.org/viewcvs/ ~ checkout ~ / jakarta-commons/collections/STATUS.html? rev = 1.13

4.5 Digester
The components of the translation into English means "compilation." Its main function is based on xml configuration files, initialization system some java class object. Digester assist you specify between XML and java object mapping model, and then permit customers customized mapping rules (rules). Detailed information please refer to
http://jakarta.apache.org/commons/digester.html

4.6 other relevant components because of the length of questions, some components have not introduced one by one, including the Database Connection Pool, Upload, Logging, Pool, Services. Struts at the base user manual has a detailed introduction, please refer to.

Friday, Struts configuration file brief introduction (Deployment Description)
struts framework in accordance with the specified configuration file (more precisely, is the controller), that makes ServletAction, ActionMapping, Action, ActionForm that some of the components at different levels of mutual interaction, co-ordination. Also mentioned in front of these configuration files are in the system to start when read into memory guide for controller use.
Struts framework mainly includes three parts of the configuration described, one is designated on the Struts Controller and its associated configuration description (Initialization Parameters), a struts tag lib at the description of a struts are components (ActionMapping, Action, ActionForm) of coordination of inter-relationship mapping

5.1 on the Struts Controller and its associated configuration described Struts Controller because the main categories are ActionServlet inherited from HttpServlet, must, like configuration so as to configure a Servlet Class ActionServlet mapping and visit. For more information please refer to:
http://jakarta.apache.org/struts/userGuide/building_controller.html # dd_config

5.2 on the struts tag lib configuration described in the web application if you intend to use the Struts-taglib, then you need to have web.xml for struts taglib configuration description. Detailed description and instructions please refer to
http://jakarta.apache.org/struts/userGuide/building_controller.html # dd_config_taglib

5.3 on the Struts Action Mapping configuration described
Struts has a configuration file itself, usually for the struts-config.xml. DTD documentation relating to their description, please refer to http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd
(Or struts-config_1_0.dtd)
General struts-config (version1.1) contains the following sections:
(1) form-bean
(2) global-forwards
(3) action-mappings
(4) data-sources
For more information please refer to
http://jakarta.apache.org/struts/userGuide/building_controller.html # config

There is a need to mention is that at struts1.1 put forward on the Multiple Application Support. Struts at the earlier version, there is only one struts configuration file, generally called struts-config.xml. However, more and more complex application system development, there is only one place that a file stored on large-scale projects, use and modify this configuration file, making it the bottleneck of an application problem. Struts1.1 at Medium, you can define many of the configuration files work together.

Summed up the hope that through the above explanation of the Struts Framework, readers can be the overall structure of Struts has a relatively clear understanding of how to deal with their customers request, how to deal with business logic and automatic circulation can have a conceptual understanding of

------

Reply to this article |
Topic Replies: Re: Struts Architecture (Study forward) | Author: haohao | rank: 6 non-commissioned officer |发表时间:2004-06-23 23:35:27
Struts development process from the Struts release version number can be seen, Struts is a new thing, she has some good parts, wise if you had to figure out when to achieve the appropriate part of the development, it would be better use of our the development time. From what I have developed some applications using Struts, I more or less summed up as follows the development of more effective steps:
1, a clear application requirements;
2, by the user input and data acquisition point of view, clear and designed a user interface;
3, determine the user interface to enter the path;
4, by the application information to determine the logic of action mapping table (ActionMapping);
5, from design to complete development of its user interface used in the class and application function;
6, the user interface from the data in the development of information and the corresponding data ActionForm validation method;
7, ActionMapping in the call will be transferred to the Action or the corresponding JSP page, this step to our development of these Action;
8, the development of commercial application of logic, that is, the corresponding JavaBean, EJB or other Dongdong;
9, the development of the system from the definition of job ActionMapping achieve flow corresponding JSP page;
10, to complete system configuration file: struts-config.xml and web.xml;
11, the compiler / test / release.

Application needs to develop a clear system for any application The first step is to collect user needs information. Regardless of the logic of a user at first glance, however reasonable, but there is probably only in the development and found it much more difficult than seemed want. Therefore, it is recommended to prepare a list of specific user needs, this is not just for the purpose of development, but also through the analysis of user requirements table to determine which places may need to spend more energy.
StrutsSample in our projects, application requirements are:
Struts framework as an application to display a complete example of the function of the completion of this example are user log. Struts are designed to clear the application, the sample will not be related to the complexity of the application of the general system of security possible applications, databases, EJB development of related technologies and so on.

Designed user interface of this application, include the following three user interfaces:
1) Login interface for user name and password input;
2) When users log in at the time of legitimate users welcomed the interface;
3) When the sign of the error message fails interface.

Determine the user interface to enter the path
1) sign the application interface as the default page;
2) welcomed the interface only when a successful log in before entering;
3) any possible error page will be prompted to enter the wrong interface;

Information identified by the application logic ActionMapping
ActionMapping for the entire application to determine the "road map", in the configuration file struts-config.xml to define ActionMapping, forward the request through the (forward) to straighten out the deal with the application of flow to determine the application corresponding to each user request for action.
Usually at our development process has gradually established the ActionMapping information needed to develop the process of code is from the draft at the beginning of one struts-config.xml perfect step-by-step process. When the Action category deal with End Users, upon request, of the forward is back at the definition of a Medium ActionMapping. Action of a forward back there is a variety of entirely possible, even though only a general definition of Action related to some of their forward. Well, if there is a number of Action are probably the same back forward, then it can be defined as the overall forward (global forward). This is similar to C's header file global variables, if the struts-config.xml to describe information in a forward is not described in the current Action defined in the definition but the overall situation, then this situation will work, same , an Action in the current definition of the overall situation will cover the definition of forward. At this we give a simple example, the definition of our global forward - "error", when an Action is to forward the return "error" of this mapping, then Errorpage.jsp page will be displayed to users, even though the current Action did not its definition.
Our continued development, the project gradually improved, project-related configuration files will be more and more detailed. In the example below, we will StrutsSample used in struts-confug.xml document as an example, studying global forward and a related Action mapping definition. Below defines a named "login" of Action, its com.oreilly.actions.LoginAction example, when users log in the success of Action will deal with a "success" of the back forward, users will see Welcome. jsp page, if the sign of failure, Action will return the corresponding forward to another show Login.jsp to the user, and if the course of treatment other errors happen, Action will return to the overall definition of forward - "error", users will see error page Errorpage.jsp.

<! - ========== Global Forward definition ->
<global-forwards>
<forward name="login" path="/Login.jsp"/>
<forward name="error" path="/Errorpage.jsp"/>
</ global-forwards>

<! - ========== Action Mapping definition ->
<action-mappings>
<! - <action> Property related elements ->
<! --
The following list only common property, other org.apache.struts.action.ActionMapping please refer to the documentation

path - the current Action corresponding user request URI path

type - the current implementation of the Action of the complete Java class name

name - the current Action in the ActionForm to use the name of the specific information in the configuration file otherwise defined in detail elsewhere

unknown - if the property is set to true, then the statement is this Action will deal with the entire application to find the appropriate treatment of all outstanding requests for Action, of course, an application system will only have an Action property of the unknown can be set to true

scope - Action in the ActionForm used the survival time, we can "request" or "session", as the survival time of setting, the Action will be at the appropriate time to be created

input - the Action in the ActionForm associated to obtain input from the user input page, as will be set to automatic verification ActionForm input data and found that illegal data error return will return the page

validate - If the property is true before the action in the Action of its corresponding ActionForm's validate method will automatically be called, is generally taken to validate user input data

forward elements - the definition of the current Action related ActionForward
->

<! - =================== ->
<! - O'Reilly Struts Sample Main Actions ->
<! - =================== ->
<action path = "/ login"
type = "com.oreilly.actions.LoginAction"
name = "loginForm"
scope = "request"
input = "/ Login.jsp">
<forward name="success" path="/Welcome.jsp"/>
<forward name="failure" path="/Login.jsp"/>
</ action>
</ action-mappings>

The previous article, we have said, struts-config.xml is the MVC model of the Controller. Struts-config.xml in determining the configuration information, they should focus more time at the top to ensure that each of the definition of Action and related definitions are in line with the needs of applications. If the project did not start the detailed design of its definition, when all the code and configuration integrated together, we will inevitably will be different parts of the code and configuration completely re-organized again.
Examples of our current StrusSample treatment because only users log in, so only need one Action. An application system by use of the Action of the number of totally depending on the size of the application. Once the full set of Action complete the definition of mapping out, one by one we will be able to develop its specific implementation of the Action and ActionForm class, and gradually achieve some integration of 1.1 points.

Design is completed by the user interface used in the development of its type and application of function
ActionForm implementation of all the categories are sub-categories org.apache.struts.ActionForm. An ActionForm with the input form on the page linked to, and implementation of the ActionForm can also input data to the user to verify the legitimacy of. As a Java Bean, ActionForm has Set and Get methods, when a page form was submitted, the system will automatically call the Set method to data Add ActionForm, and the Get method will operate in Action provided by these data. Generally speaking, deal with all the data in the form and verify the legitimacy of both is entirely possible to achieve by the ActionForm. At application, For me personally, tend to ActionForm and Action divided into different package, because when a page to use to several of ActionFrom and Action, they will be placed in a bag of confusion. The following code example is the sign used ActionForm page code.

/ *
* LoginForm.java
* /
package com.oreilly.forms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/ **
* Validate the user to use the two data
*
* Username - User Login
* Password - user password
*
* /
public final class LoginForm extends ActionForm (
private String userName = null;
private String password = null;

/ **
Get the * userName Ways
* @ Return String
* /
public String getUserName () (
return (userName);
)

/ **
Set the * userName Ways
* @ Param userName
* /
public void setUserName (String newUserName) (
userName = newUserName;
)

/ **
Get the * password Ways
* @ Return String
* /
public String getPassword () (
return (password);
)

/ **
Set the * password Ways
* @ Param password
* /
public void setPassword (String newPassword) (
password = newPassword;
)

/ **
* Reset all the data
*
* @ Param mapping the current ActionMapping
* @ Param request the current Server is processing the HttpServletRequest
* /
public void reset (ActionMapping mapping, HttpServletRequest request) (
userName = null;
password = null;
)

/ **
* Verify the current HTTP request data that is submitted
* If data validation data found unlawful, the back of a package
* All validation errors ActionErrors object
* If data validation is passed, the method returns null or a
* NOT package any validation errors ActionErrors object
*
* @ Param mapping the current ActionMapping
* @ Param request the current Server is processing the HttpServletRequest
* /
public ActionErrors validate (ActionMapping mapping,
HttpServletRequest request) (
ActionErrors errors = new ActionErrors ();
/ / The current ActionForm, only need to check the user name entered by the user data
if (userName == null | | userName.length () == 0) (
errors.add ( "userName", new ActionError ( "error.userName.required"));
)
return (errors);
)
)

The above code, only two points and the Java Bean in general be different. One is the reset method, method of setting the value will be reset in the form response to its corresponding table on the individual, the individual table of data is about to restore to default values. The second is validate methods are used to authenticate users in the form of the input data. In this example, we only validate the user input user name. Since a user name of its corresponding password may be empty, so our logic is not to check password authentication. Authentication user name, when found to enter the user name is empty, the method will result in an error object (ActionError).
ActionErrors used in Struts to load a number of errors, from the end of ActionErrors that "s" we can know that she is a collection of objects ActionError. Validate user input at the time, you can validate all the form data, then that may be found in a number of errors through the ActionErrors back to users, such logic should be taken for granted you can not have five different user input error, have prompted five minutes to allow users to modify it to submit five times, huh, huh.
At the same time, we want to know at this example, we will give an error message prompts the user through the document ApplicationResource.properties. The document adopted at Tomcat startup in web.xml is defined as used in this application. Generally, each application in its WEB-INF directory has web.xml file to describe the system, and about the deployment of the application of specific structural information, please refer to Tomcathttp: / / jakarta.apache.org / tomcat / index.html, etc. Server-related user manuals.
ApplicationResource.properties paper applications can be defined to prompt use of the information string, the string is only through a key to determine its location. In our example, the keys corresponding to the string error.userName.required information are "A username is required", in the error message displayed to the user when the keys will be identified through the error revealed that the string. Through such a mechanism for us in the system implementation language has facilitated many of the documents translated into these strings corresponding language, our system can achieve Spanish, German, French and Chinese languages and so on a.
ApplicationResource.properties in the following information for us this simple example has been good enough for us:

login.title = Login Struts Sample
error.userName.required = A username is required
error.login.authenticate = Invalid username / password
errors.footer = </ ul> <hr>
errors.header = <h3> <font color="red"> Page
Validation </ font> </ h3> Please correct the
following error (s) before contiuing: <ul>
applicationResources = Cannot load application resources bundle
(0)

Page title, button or any other place the necessary texts prompted the adoption of the document can be used to define the string. We will be at the series final in an article, that is, the development of some follow-up steps on how the Struts tags from this document used to obtain the string