Home >Java >javaTutorial >Struts User and Development Guide (Part 1)

Struts User and Development Guide (Part 1)

黄舟
黄舟Original
2016-12-17 10:54:001164browse


 0.1 Overview
 This user guide is written for those who are passionate about web development and those who want to develop web applications using java. Before starting to read, you should have some basic knowledge of the following core technologies:
 .HTTP, Html and User Agent;
 .HTTP request response cycle;
 .Java language and application framework;
 .JavaBeans;
 . Property files and resource binding;
 .Java Servlet;
 .jsp and JSP tag library;
 .xml language;
  This chapter only gives a brief introduction to these core technologies without giving a detailed description. For your convenience, we provide you with some useful links to learn more about them.
 If you are already familiar with the Java language itself but do not know these technologies, we recommend that you take a good look at this guide The Java Web Services Tutorial. A PDF version of it can be downloaded here.
 If you already have experience in developing web applications for other platforms, you can also find the information you need here. Because the technologies used in Struts may also be used in other Java Web products, this background knowledge is useful for any Java project.
 If you still don’t know much about the Java language, then we recommend that you take a look at another guide, The Java Tutorial. The content of The Java Tutorial and The Java Web Services Tutarial may overlap, so it is best to read them together.
 If you want to know how to develop general Java applications, then you can go here and take a look http://developer.java.sun.com/developer/onlineTraining/new2java/divelog/part1/toc.jsp' TARGET=_blank> New to Java , might help you a lot.
 
 0.2 HTTP, HTML and User Agents
  As we all know, the Internet is built on the HTTP protocol and HTML language. The User Agent uses the HTTP protocol to request an HTML document just like a Web browser, and the browser is responsible for formatting and displaying it to the user. The HTTP protocol is used for transmission, while HTML is the universal language used by the web and web applications.
When developing web applications, some Java programmers may write HTML language themselves, while others will leave it to specialized page designers to write.
 For more knowledge about HTTP, HTML and User Agents, please refer to the following resources:
 .Getting started with HTML by Dave Raggett;
 .HTTP Overview in Java Web Services Tutorial;
 .HTTP/1.1 specification;
 .HTTP Basic and Digest Authentication specification;
 .State Management Mechanism specification (Cookies);
 0.3 HTTP request response cycle
 For web developers, the most concerned about HTTP is the HTTP request response cycle. Use HTTP to submit a request, and then the HTTP server ( such as a web server) returns a response. When we do web development and design, we design an HTTP request to return an HTTP response. The Struts framework abstracts this cycle, and what is more important to us is that we should know what is happening behind the scenes.
 If you are not familiar with the HTTP request response cycle, then we strongly recommend you to read the HTTP Overview in the Java Web Services Tutorial http://java.sun.com/webservices/docs/1.0/tutorial/doc/HTTP. html#63796
 
 0.4 Java language and application framework
 The Struts framework is written in Java, the most popular universal programming language (Translator's Note: I don't think it is an exaggeration to describe the Java language like this). Java is an object-oriented programming language, and Struts takes advantage of its object-oriented technology. In addition, Java itself has good support for threads and can perform multiple tasks at the same time. A good understanding of Java language, object-oriented programming and threads will be of great benefit to us in mastering Struts and using this user guide.
 To learn Java language and threads, you can refer to the following materials:
 .Learning the Java Language of The Java Tutorial;
 .Learning the Threads-Doing Two or More Tasks At Once of The Java Language Tutorial;
 Even if you have already used Java and oriented Object programming, creating and using application frameworks will also be of great help to your programming. For more knowledge about application frameworks, you can refer to the following two white papers: Designing Reusable Classes by Ralph E. Johnson and Brian Foote; Object-Oriented application Frameworks by Mohamed Fayad and Douglas C. Schmidt; if you are looking for A server-side framework Then these two pages may be of some help to you: 1 and 2
 
0.5 JavaBeans
Like many Java applications, most Struts objects are designed as JavaBeans. Using the JavaBean design pattern makes Struts classes more accessible to Java developers and Java deployment tools.
 JavaBan was originally created only for visual element programming. Now this object design pattern has been widely used in the basic design of more reusable components, such as the Struts framework.
 For more knowledge about JavaBeans, please refer to:
 The JavaBeans Component Architecture document in .java.sun.com. tion and JavaBeans 1.01 Specification;
  .The JavaBean Trail in The Java Tutorial;
JavaBeans Components in JSP Pages in The Java Web Services Tutorial;
 0.5.1 Reflection and introspection mechanism
 
 Reflection is a processing mechanism that determines which member variables or methods of an object are available. Introspection is a special form of reflection used by the JavaBean API. Using introspection we can know which methods of JavaBean can be accessed by other objects.
 The Struts framework uses the introspection mechanism to convert HTTP parameters into JavaBean properties and uses JavaBean properties to assemble HTML form fields. This technology makes it easier to "bidirectionally access" properties between JavaBeans and HTML form fields.
 For more about reflection and introspection, please refer to:
 .The Reflection Trail;
 .Chapter 8 of the JavaBeans API Specification;
  0.5.2 Maps
  
 JavaBeans store data in other methods by using properties Manipulate this data. JavaBean is a convenient and powerful object, but it is not the only choice for programmers to use to store data. Another popular object is Map [java.util.map]. A map is a simple collection of name-value pairs. Mapping often works "behind the scenes" as a convenient way to store dynamic data.
 
 0.5.3 Dynamic Beans (DynaBeans)
 
  Dynamic Beans combine the scalability of JavaBeans and the flexibility of Maps. We know that even if we want to define a simple JavaBean, we must create a new class, define an attribute variable, and write two access methods (setXXX and getXXX) corresponding to each attribute. Dynamic beans can define properties through XML configuration files. The virtual properties of dynamic beans cannot be called like ordinary Java methods. Instead, they must be accessed through components using reflection and introspection mechanisms.
 In the Struts framework, you can use dynamic beans to describe an HTML form. This strategy avoids having to create formal JavaBean subclasses for simple form fields.

The above is the content of the Struts User and Development Guide (Part 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