Basic struts knowledge

Source: Internet
Author: User

Basic struts knowledge

1. Framework

(1). It is a series of jar packages, and its essence is to expand JDK functions.
(2). The framework is a set of programs that contain a series of best practices to solve problems in a certain field.

2. Role of the framework:

The framework emphasizes software design reusability and system scalability to shorten the development cycle of large-scale application software systems and improve the development quality. Compared with the traditional class library-Based Object-Oriented reuse technology, the application framework focuses more on software reuse in specialized fields.

3. Differences between frameworks and Design Patterns
Many programmers often confuse the framework and design patterns and think that MVC is a design pattern. In fact, they are completely different concepts.

(1). The concepts of frameworks and design patterns are always confusing. In fact, there are still differences between them. The framework is usually code reuse, while the design pattern is design reuse. The architecture is between the two. Some code reuse, some design reuse, and sometimes analysis can also be reused. There are three levels of reuse in software production: Internal reuse, that is, abstract blocks that can be commonly used in the same application; code reuse, which combines common modules into libraries or tool sets, it can be used in multiple applications and fields. the reuse of application frameworks provides general or ready-made infrastructure for specialized fields to achieve the highest level of reusability.

(2). Although the framework is similar to the design model, it is fundamentally different. The design pattern is a description of the problem that occurs repeatedly in a certain environment and the solution to the problem. It is more abstract than the framework. The framework can be expressed in code and can be directly executed or reused, for patterns, only instances can be represented by code. design patterns are smaller elements than frameworks. A framework usually contains one or more design patterns, the framework always targets a specific application field, but the same pattern can be applied to various applications. It can be said that the framework is software, while the design mode is software knowledge.
(3) What are the framework modes?
MVC, MTV, MVP, CBD, ORM, etc;
(4) What are the frameworks?
C ++ QT, MFC, gtk, Java SSH, SSI, php smarty (MVC mode), python django (MTV mode), etc.
(5) What are the design patterns?
Factory mode, adapter mode, policy mode, etc.
In short: the framework is wise and used to divide software design. The design mode is a small skill. It proposes solutions to specific problems to improve code reuse rate and reduce Coupling Degree.

4. Five Elements of best practices:
(1) Readability
(2) maintainability
(3) scalability
(4) Simple is Beauty ):
Eliminate duplication and simplify traditional features
Simple must be readable, simple, and extensible
(5) reduce dependencies and eliminate coupling

5. Best practices in Web development-hierarchical development mode
During Java EE development, the entire program is vertically divided based on functional responsibilities (technically "divide and conquer "). Different levels of responsibilities are not allowed:
Predentation Layer: responsible for processing interface interaction-> (Struts2)
Business Layer: Responsible for complex Business logic computing and judgment --> (Spring)
Persistent Layer: stores business logic data persistently --> (Hibernate)

6. MVC Mode

MVC is a framework model that forcibly separates the input, processing, and output of an application. MVC applications are divided into three core components: model, view, and controller. They process their own tasks. The most typical MVC is the JSP + servlet + javabean mode.

The MVC Architecture Model does not introduce new functions, but is used to guide us to improve the application architecture, so that the application model and view are separated, to achieve better development and maintenance efficiency.

Data Model: encapsulates the state of an application and implements its functions. Data Models are usually divided into data models and business logic models. data models are used to store business data, such as order information and user information. business logic models include business operations of applications, for example, add or modify an order.

View: this interface is used to display the model content to users. Users can request the model to be updated through the View. The view obtains the data to be presented from the model and then presents the data to the user in its own way, which is equivalent to providing an interface for human-computer interaction with the user. After the user completes operations on the interface or fills in the information, click the submit button or send a request to the Controller in other trigger events.


Controller: used to control the application process and process the requests sent by the view. After the Controller receives a user request, It maps the user data to the model update, that is, it calls the model to implement the user request function; then, the Controller selects the view for the response and displays the updated model data to the user.

Mode chart:

7. struts

Developed from the traditional Struts1 and WebWork frameworks
Struts2 framework = Struts2 + XWork

8. core features of Strust2
(1). Allow POJO (Plain Old Java Objects) Objects as actions
(2) The Action execute method is no longer coupled with the Servlet API and easier to test.
(3). Support for more view technologies (JSP, FreeMarker, and Velocity)
(4) interceptor mechanism based on Spring AOP, which is easier to expand
(5) more powerful and easy-to-use input verification functions
(6) How to Integrate Ajax support? Http://www.bkjia.com/kf/yidong/wp/ "target =" _ blank "class =" keylink "> WPGJyPgo8L3N0cm9uZz48L3A + CjxwPjxzdHJvbmc + signature + Signature =" http://www.2cto.com/uploadfile/Collfiles/20140815/20140815092136318.png "alt =" n fast tease 'your I rough corner tJ Accuracy dark red pox g (X + k mark 6n)] cj g ← J ← forging limit n? Limit limit 6? Dr. r Xun j. y red pox f. f Z + k mark 6P y? Too many? Comment 'items? Direction \ cj? + K marks 6n tea leaves I have been beaten by the Mio Zw] Why? Http://www.bkjia.com/kf/all/zujian/ "target =" _ blank "class =" keylink "> component, which needs to be added after version 2.1.6
Commons-io-2.0.1.jar: The jar package for transferring file Dependencies
Commons-lang-2.5.jar: enhancements to java. lang packages

10. front-end controller: Design Mode in J2EE:
It mainly provides a controller that can centrally manage requests. A front-end controller can accept all customer requests and send each request to the corresponding request processing object (Action/Controler ), and respond to the user as appropriate.
The front-end controller completes most of the common functions and submits specific operations to various actions.

ThreadLocal is also called a "Thread Local variable". It provides a copy of the variable value for every thread that uses this variable,
So that each thread can change its own copy independently without conflict with the copies of other threads.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.