JAKARTA-STRUTS-1.2.4 code reading

xiaoxiao2021-04-08  284

First, Stuts Working Principles:

1, the settings in web.xml are as follows

action org.apache.struts.Action.ActionServlet

config

/web-inf/struts-config.xml

2

Servlet defines the access tag, class name, initialization parameter, and load order of servlets you need to use.

Servlet-name: Defines the label used when visiting servlet

Servlet-Class: Points the class name (including the package) of servlets.

INIT-PARAM: The parameters you need to initialize the servlet, you can use GetServletConfig () in the servlet. GetInitParameter ("config") method acquires the passing parameters. It is also possible to define sub-applications as "config / xxx".

Load-on-startup: Defines the order of servlet containers to load servlet. You can only set positive integers and 0, and the servlet container is loaded in any order when you enter non-numbers, negative or no settings. When set to positive integers, loaded when the container is started, and the number is small in front of the digital large.

Action

*. do

Servlet-mapping: Defines the rules used when the container is used when distributing user requests. In order to explain that when the container receives the request of the .do end, call the action servlet to process!

Servlet-name: The label of the servlet that needs to be called

URL-Pattern: Defines the format that the container matches when distributing user requests. Now I only know two kinds of * .xx and / xx

Note: If you want to replace the Struts default ActionServlet, you can define yourself yourself, replace servlet-class.

2, Struts-config.xml configuration

Debug = "0"

Locale = "True"

Nocache = "true"

Processorclass = "jp.co.nttdata.terasoluna.framework. Web.richclient.requestprocessorex" />

Dequessed the RequestProcessor class called by the ActionServlet, and the RequestProcessor class completes the request distribution in all Struts.

3, multiple sub-application

Multiple sub-applications can be defined and supported in Struts 1.1. This means you can put your application in a more easily maintained sub-app. You no longer need to detect source control outside the unique struts-config.xml file.

Another reason for the use of sub-applications is the control flow changed according to the customer. In some applications, you may have some universal pages, but the control flow may change due to the different customers of landing applications. You can store the metadata of this control flow into the database and generate a web.xml file (or part of the file), together with different struts-config.xml files. If you have developed Struts 1.x, you may notice that the elements in many web.xml files have been moved to the struts 1.1 Struts-Config.xml file. This is because now they are Application-Specific. Multiple sub-applications are determined by the prefix starting with respect to the context part in the request URI. If there is no application prefix to match, select the default configuration. The default setting has an empty string prefix. This way to perform the default settings is backward compatible with Struts 1.0.x that may define an application.

If you have a large application that contains different functional modules, you will make more meaningful applications with a sub-application that runs together. When using sub-applications, you may define a context-related request URI to specify which subscriber use.

4, JAKARTA universal library integration

Struts

Toolkit can be solved in creation

Web

An emerged problem when applying. Most of this package does not depend on the controller

Servlet

Frame or customized tag library, so they can be used in general

Java

Application programming. in

Struts 1.1

In the version, many classes in this package are ported to

Jakarta

Public projects. These classes include

Bean

tool,

Colections

,as well as

Digester

package.

Struts

Provided

Logging

In fact, from public projects

Org.apache.commons.beanutils

Component package

Java

of

REFLECTION

versus

Introspection

Application programming interface (

API

). use

Beanutils

The class in the package can be dynamically called in the case where the unknown method is compiled.

Getter

versus

setter

method. These types

Struts

The custom tag library calls, so you can define additional custom tags for your application, you may want to learn more about the available content in this package. table

1

These are listed.

Table 1: General Package BeanUtils in Struts 1.1 BeanUtils Converts String Values ​​to Specified Class Values ​​to Specified Class MappedPropertyDescriptor Description and Mapping Properties MethodUtils Concentrated to PropertyUTils Use Java Reflection Application Programming The interface (API) provides a setter of the XML document with the GetTER operation Digester package for the general property.

It is very important to read the configuration file to make the correct initialization object. This package can be you very simple to complete these things. Otherwise, you need to know more deeply.

DOM

or

SAX

Treatment. when

Xml

The mode is verified, which can be done by specifying the object mapping module of the rule. This includes the ability to embed the engine that matches your own mode, legal namespace processing, and for multiple applications and encapsulate rules

RuleSets

.

If you have a clear read XML file, you need to map to the appropriate Java object, and the Digester package is very useful.

转载请注明原文地址:https://www.9cbs.com/read-132855.html

New Post(0)