Home >Java >javaTutorial >Learning Jakarta Struts 1.1 (1)

Learning Jakarta Struts 1.1 (1)

黄舟
黄舟Original
2016-12-17 10:45:421353browse

This article is the first half of the article about Jakarta Struts 1.1. Part of the article is from Sue Spielman's book "The Struts Framework: PRactical Guide for java Programmers (Morgan-Kaufmann) / Struts Framework Java Programmer's Practical Guide". This book is one of the first books on the market that provides a comprehensive and detailed introduction to Struts 1.1. You can contact Sue at sspielman@switchbacksoftware.com.
 
Last year, the Struts framework (a Jakarta kaiju project) has become the de facto standard for building web applications. Struts has proven itself to be a reliable framework based on the MVC pattern architecture and can be used in various systems. In fact, I was forced to come up with a reason why my development team and I would spend a cycle developing a custom MVC pattern framework for the project. This is a bit incomprehensible.
 
 Struts v1.1 is the latest version of this framework. At the time of writing this article, Struts v1.1 is still in beta2, and the final version will be released soon. There may seem to be no reason why you should start learning to use v1.1 now, but why not; in fact, there are many reasons why we should use this version.
 
 This article has two parts. In the first part here, we briefly introduce the integration and multi-application support of Jakarta universal library. The second part will focus on nested tag libraries, plug-in APIs, and exception handling declarations. The new version has made some important improvements to the framework, and you may want to start new development with this version. In fact, I highly recommend it. Maintaining backward compatibility with v1.0.2 has been a permanent goal of the Struts project participants, and they have done a great job with v1.1. At the end of this article, we will point out some issues that need to be paid attention to when upgrading from v1.0.2 to v1.1.
 
 This article is not an introductory reading to Struts. We assume that you are already familiar with the various components of this architecture. If you need to take a look at the introductory introduction first, please read the three-part introduction to the Struts framework I wrote (http://www.onjava.com/pub/a/onjava/2001/09/11/jsp_servlets.Html).
 
UPDATE
There have been exciting features and improvements to Struts throughout the development of v1.1. We'll take turns introducing them, but first let's take a look at what's new.
  The use of Jakarta general libraries, such as BeanUtil and Logging;
  DynaActionForms can create dynamic action forms without writing any code;
  Multi-application support allows the definition of multiple struts-config.xml configuration files;
  Nested tags The library makes it easy to access the nested object system in JSP pages;
  Tiles and Validator provide advanced templates and form validation expressions;
  The plug-in API can enhance the functions of ActionServlet;
  Exception handling statements enable Actions Don't worry about catching all exceptions.
 Let’s take a look at each feature one by one.
 
 Integration of Jakarta universal library
 The Struts toolkit can solve the problems that constantly arise when creating web applications. Most of the classes in this package do not rely on the controller Servlet framework or custom tag libraries, so they can be used in general Java application programming. In the Struts 1.1 release, many classes in this package were ported to Jakarta's public projects. These classes include Bean tools, Collections, and Digester packages. The logging provided in Struts actually comes from public projects. The org.apache.commons.beanutils component encapsulates Java's Reflection and Introspection application programming interface (API). Using the classes in the beanutils package, you can dynamically call getter and setter methods without compiling unknown method names. These classes are called using Struts' custom tag library, so additional custom tags can be defined for your application. You may want to learn more about what is available in this package. Table 1 lists these.
 
 Table 1: Common packages in Struts 1.1
  BeanUtils assembles JavaBeans properties through reflection
ConvertUtils Converts string values ​​into objects of specified classes
MappedPropertyDescriptor describes and maps properties
MethodUtils focuses on general methods rather than details such as attributes
 PropertyUtils uses the Java Reflection application programming interface (API) to perform setter (setting value) and getter (getting value) operations on general properties
  
 The Digester package provides rules based on XML documents. Doing this is very important to read the configuration file so that the object can be initialized correctly. This package makes it very simple for you to do things that would otherwise require you to have a deeper understanding of DOM or SAX processing. When the schema in the XML is validated, this can be done through the object mapping module, which specifies rules. This includes the ability to embed your own pattern matching engines, legal namespace handling, and RuleSets that encapsulate rules for use in multiple applications. The Digester package is useful if you explicitly read an XML file that does not need to be mapped to an appropriate Java object.

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

Statement:
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