Home Java javaTutorial Learning Jakarta Struts 1.1 (2)

Learning Jakarta Struts 1.1 (2)

Dec 17, 2016 am 10:46 AM


  DynaActionForm
 
  DynaActionForm provides a convenient mechanism that essentially eliminates the need to write an ActionForm. DynaActionForm allows dynamic form properties. This means that you can define properties in your struts-config.xml file and set the form type to org.apache.struts.action.DynaActionForm. Nothing needs to be written. DynaActionForm uses DynaBean from the Apache public project to complete these operations. This dynamic behavior is provided through reflection and hashmaps.
  
  DynaActionForm is defined using tags in the struts-config. The attribute name is used to index the form bean in the Action, and type is used to specify the instantiated class. When using class DynaActionForm, the dynamic properties automatically default to true. For DynaActionForm, all properties of the form are specified using elements. The name in the element refers to the attribute name. Type refers to the class name of the Java implementation class of the bean attribute. If this attribute is of index type, add "[ ]" after type. In the above table, you should pay attention to the definition of the last attribute genre. We set the initial value (or default value) to "Dance". This value will also be set as the default value when the reset() method in DynaActionForm is called, and allows a mechanism to set default values ​​in the form. If no value is specified in the initial attribute, then the initial value of all primitive types is set to 0, if it is an object, the initial value is null (empty).
 
 Using DynaActionForm is very convenient. One of the main benefits is that you only need to write very little code. Just like other forms, the preceding code example is all the code you need to use the form. One thing to know is validation. When using DynaActionForm, it is assumed that validation processing is done somewhere, which is somewhat different from ActionForm. You can implement validation in your own Action, but this is a better approach.
 
 For verification, you can use DynaValidatorForm or DynaValidatorActionForm. Both classes are in the org.apache.struts.validator package. By extending DynaActionForm, you can get validation based on basic value fields of XML files. Validation is based on the key entered into the validator. Key is the name attribute from the struts-config.xml file. It should match the name attribute of the form element in the validation.xml file.
 
 Multiple application support
 In Struts 1.1, multiple sub-applications can be defined and supported. This means you can put your application in a sub-application that is more maintainable. You no longer need to detect source control outside of the single struts-config.xml file.
 
Another reason to use subapplications is to change the control flow based on the client. In some applications, you may have some common pages, but the control flow may change depending on the client logging into the application. You can store this control flow metadata in a database and generate a web.xml file (or part of it), along with a different struts-config.xml file.
 
If you have ever developed for Struts 1.x, you may have noticed that many elements in the web.xml file have been moved to the struts-config.xml file of Struts 1.1. This is because now they are application-specific. Multiple sub-applications are identified by the prefix that begins with the relative context portion of the request URI. If no application prefix matches, the default configuration is selected. The default setting has an empty string prefix. This way of implementing default settings is backwards compatible with Struts 1.0.x where only one application may be defined.
 
 If you have a large application that contains different functional modules, it makes more sense to replace one huge application with sub-applications that run together. The file web.xml shown below shows how to define a sub-application.
  
  
  config
  /WEB-INF/struts-config-config.xml
  
 
 
 
  
  config/catalog
  /WEB-INF/struts-config-catalog.xml
 
 
 
 
  
  config/sorter
  /WEB- INF/struts-config-sorter.xml
   
  
  
  When using sub-applications, you may define context-sensitive request URIs to specify which sub-application is used. For example, an action on a form might look like this:
  
  
  which references the default sub-application, or
  
  
  which refers to the action class of the catalog sub-application. You don't actually have to do this. You can use /listCds in the catalog sub-application if you want to do this. The basic rule is: all struts-config.xml parameters that were context-sensitive in version 1.0 are now sub-application prefix-specific in version 1.1. In this way, a single application can serve as both a default sub-application and a designated sub-application without modification.

The above is the content of learning Jakarta Struts 1.1 (2). For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

See all articles