-
Notifications
You must be signed in to change notification settings - Fork 0
- 9-up
- Seven Dwarves
Official statement: SSH is an integrated framework of struts+spring+hibernate and a popular open source framework for web applications.
SSH is not a framework, but a close combination of multiple frameworks (Struts, Spring, and Hibernate) to build flexible, easy-to-extend multi-tier Web applications.
The SSH framework set is a framework set that will be used in most software design processes. This kind of framework is based on MVC development, and the MVC model has become a common pattern in modern J2EE development, and is welcomed by more and more developers such as JSP and PHP. The MVC pattern is Model, View, and Controller.
After the application is divided into these three parts, each process its own task. The view layer extracts the user's input information and submits it to the controller. The controller determines that the request is handed over to the model layer according to a certain choice. The model layer processes the user request according to the code of the business logic and returns the data. The view layer is displayed to the user.
The aforementioned SSH framework set is a good counterpart to the development and use of the MVC pattern. This integration of the three major frameworks of Struts + Hibernate + Spring fits the three-layer object of the MVC pattern. Among them, Struts corresponds to the control layer of the front desk, while Spring is responsible for the business logic processing of entity beans, while Hibernate is responsible for the handover of the database and the use of Dao interface to complete the operation.
The Java EE architecture is roughly divided into the following levels:
Physical layer (POJO layer). Data access layer (DAO layer). Business logic layer (Service layer). Controller layer (Controller layer). Presentation layer (View layer). In terms of function, the system of SSH framework can be divided into four layers: presentation layer, business logic layer, data persistence layer and domain module layer (entity layer).
The basic business process of building the system by SSH is as follows:
-
In the presentation layer, the interactive interface is firstly realized through the JSP page, which is responsible for sending the Request and receiving the Response. Then, Struts delegates the Request received by the ActionServlet to the corresponding Action according to the configuration file (struts-config.xml).
-
In the business layer, the Spring IoC container that manages the service component is responsible for providing the Action with the business Model component and its collaborating object data processing (DAO) component to complete the business logic, as well as container components such as transaction processing and buffer pools to improve system performance and ensure data integrity.
-
In the persistence layer, it relies on Hibernate's object mapping and database interaction to process the data requested by DAO components and return the processing results.
Using the above development model, not only the view, controller and model are completely separated, but also the business logic layer and the persistence layer are separated. In this way, no matter how the front end changes, the model layer only needs a few changes, and the changes of the database will not affect the front end, greatly improving the reusability of the system. Moreover, due to the small coupling degree between different layers, it is beneficial for team members to work in parallel, which greatly improves the development efficiency.
The Struts Framework was originally developed by Craig McClanahan and was then given to the Apache Foundation in May of 2000 under the Apache Jakarta Project and became known as Jakarta Struts. It eventually became a top-level Apache project in 2005 and was eventually replaced by Struts 2, which was released in February 2007.
In terms of simplicity, Struts is the simplest of the three frameworks, which is based on MVC. It adopts JavaServlet/JSP technology to realize the application framework of MVC design pattern based on Java EEWeb application, which is a concrete realization of MVC or a concrete product of MVC.
The core of Struts is also the core of MVC. Struts is a concrete product of MVC.
| Contain | introduce |
|---|---|
| Model | ActionForm is composed of Action, ActionForm and JavaBean. ActionForm is used to encapsulate the parameters of user requests into ActionForm objects, which we can understand as entities. ActionServlet is forwarded to Action, which handles user requests and returns the processing results to the interface |
| view | This part USES JSP+ a large number of taglib, to achieve page rendering |
| Controller | As the core Controller of Struts, Controller is responsible for intercepting user requests and implementing the function of handling user requests by invoking the Model |
-
Intelligent defaults in all configuration files: One of the useful features of Struts 2 is their default values. Hence users do not need to change or set the obvious default values in configuration files.
-
Use of OGNL: Struts 2 uses elegant expression language called OGNL which is more powerful and flexible then JSTL. OGNL stands for Object Graph Navigation Language. It supports AJAX implementation in UI. Struts 2 also supports AJAX enabled tags.
-
Ready to use view components: Struts2 tags provide style sheet driven form tags which reduce coding efforts and coding of form validations.
-
Strong validation support: Struts2 supports Xwork validation framework which provides client side and server side validation. It provides manual validation as well with the support of Validate() method but most of the time developer needn't go for the manual validation.
-
Type conversion mechanism: Type conversion in Struts 2 is supported by OGNL. In Struts 1 all the properties are mostly of String type but in Struts 2 these properties can be of any type.
-
Decoupling of view from Action classes: In Struts 2, one view can be associated with multiple action classes.
-
Simple Implementation: Action classes are not tightly coupled with ServletContainer. In addition to this, Action class need not have ‘execute’ method implemented in it. There are very less dependency on Struts core library. Action class can be a simple POJO. Similar to action classes, ActionForm can also be a simple POJO.
First, Struts is an implementation of MVC that USES servlets and JSP tags (part of the J2EE specification) as part of the implementation.
Struts inherits the features of MVC and makes corresponding changes and extensions according to the characteristics of J2EE, weakening the coupling between the business logic interface and the data interface, and making the view layer more variable
In addition, struts has the function of page navigation, which makes the context of the system clearer. Through a configuration file, can grasp the whole system between the various parts of the connection, which has great benefits for the later maintenance. This is especially true when another group of developers takes over the project.
As a J2EE application framework, Spring is a container framework for lightweight IoC(Inversion of Control) and AOP(aspectway Programming). It is a lightweight container for javabeans' life cycle management, which can be used independently or in combination with Struts and Hibernate frameworks.
The Spring framework is a layered architecture consisting of seven well-defined modules. The Spring modules are built on top of a core container that defines how beans are created, configured, and managed.
| Spring Core Container | this is the base module of Spring and provides spring containers (BeanFactory and ApplicationContext)1 |
| Spring DAO | The abstraction layer of DBC and Dao provides a meaningful exception hierarchy, which can be used to manage exception handling and error information thrown by different database vendors. Exception hierarchies simplify error handling and greatly reduce the amount of code that needs to be written, such as opening and closing links. |
| Spring ORM | Spring framework inserts several ORM frameworks to provide relational tools for ORM objects, including hibernate, JDO, ibatis SQL map, etc., all of which conform to spring's common things and Dao exception hierarchy. |
| Spring Context | Spring context is a configuration file that provides context information to the spring framework. The spring context includes enterprise services such as JNDI, EJB, email, internationalization, validation, and scheduling capabilities. |
| Spring Web MVC | MVC framework is a full-featured MVC implementation of building web applications. Through the policy interface, the MVC framework becomes highly configurable. MVC contains a large number of view technologies, including JSP, POI, etc. the model is composed of JavaBeans and stored in M. the view is an interface, which is responsible for implementing the model and the controller represents the logic code. The functions of the spring framework can be used in any J2EE server, and most of them can also be used in an unmanaged environment. The core point of spring is to support reusable business and data access objects that are not bound to specific J2EE services. There is no doubt that such objects can be reused between different J2EE environments, independent applications and test environments. |
| IoC(Inversion of Control) | Inversion of responsibility for object creation. In spring, the BeanFacotory is the core interface of the IoC container, responsible for instantiating, locating, configuring objects in the application and establishing dependencies between these objects.XmlBeanFacotory implements the BeanFactory interface, and by obtaining the XML configuration file data, it forms the application objects and the dependencies between the objects.There are three types of injection in spring, one is set injection, one is interface injection, and the other is constructor injection |
| AOP(Aspect oriented programming) | Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns or behaviors that crosscut typical lines of responsibility, such as logging and transaction management.The core construct of AOP is the aspect, which encapsulates the behavior that affects multiple classes into reusable modules |
Without Spring, Struts and Hibernate can run well, I call this mode "single log bridge", but with Spring, Struts and Hibernate can better combine together and coordinate their work. I call this model "sunshine avenue." The core ideas of Spring are IoC and AOP. Spring makes it more convenient to manage objects, greatly reduces the coupling between components, and realizes the decoupling between different layers of software. There are many other advantages of Spring that we won't talk about.
Hibernate is a framework of ORM(object-relation Mapping) solution in Java language, which realizes the data persistence function. Hibernate can map the JOPO entities represented by the object model into the relational model structure based on SQL, which maximizes the object encapsulation of JDBC, enabling programmers to manipulate the database through object-oriented programming thinking.
| Contain | introduce |
|---|---|
| SessionFactory | The configuration object is used to create a SessionFactory object, configure Hibernate for the application in turn using the supplied configuration file, and allow the instantiation of a session object.The SessionFactory is a thread-safe object and is used by all threads of the application.The SessionFactory is a heavyweight object so it is usually created at application startup and saved for later use.Each database requires a SessionFactory object using a separate configuration file.So if you're using multiple databases you're going to create multiple SessionFactory objects. |
| Session | A session is used for the physical connection to the database.The Session object is lightweight and is designed to require interaction with the database for each instantiation.Persistent objects are saved and retrieved through the Session object.Session objects should not be left open for long periods of time because they are not normally thread-safe, and they should be created and destroyed as needed. |
| Transaction | Transaction object to specify the atomic unit of work, it is an option. Org. Hibernate. The Transaction interface provides Transaction management method |
| Query | Query objects use SQL or Hibernate Query language (HQL) strings in the database to retrieve data and create objects.An instance of a query is used to link query parameters, limit the number of results returned by the query, and ultimately execute the query |
| Criteria | The Criteria object is used to create and execute a rule query-oriented object to retrieve the object |
| Configuration | Configuration objects are the first Hibernate objects you create in any Hibernate application, and are often created only during application initialization.It represents a configuration or properties file required for Hibernate, and the configuration object provides two basic components.Database connection: one or more configuration files supported by Hibernate.These files are hibernate.properties and hibernate.cfg.xml.Class mapping Settings: this component creates a connection between a Java class and a database table |
Hibernate was started in 2001 by Gavin King with colleagues from Cirrus Technologies as an alternative to using EJB2-style entity beans. The original goal was to offer better persistence capabilities than those offered by EJB2; by simplifying the complexities and supplementing certain missing features.
In early 2003, the Hibernate development team began Hibernate2 releases, which offered many significant improvements over the first release.
JBoss, Inc. (now part of Red Hat) later hired the lead Hibernate developers in order to further its development.
In 2005, Hibernate version 3.0 was released. Key features included a new Interceptor/Callback architecture, user defined filters, and JDK 5.0 Annotations (Java's metadata feature). As of 2010, Hibernate 3 (version 3.5.0 and up) was a certified implementation of the Java Persistence API 2.0 specification via a wrapper for the Core module which provides conformity with the JSR 317 standard.
In Dec 2011, Hibernate Core 4.0.0 Final was released. This includes new features such as multi-tenancy support, introduction of ServiceRegistry (a major change in how Hibernate builds and manages "services"), better session opening from SessionFactory, improved integration via org.hibernate.integrator.spi.Integrator and auto discovery, internationalization support, message codes in logging, and a more distinction between the API, SPI or implementation classes.
In December 2012, Hibernate ORM 4.1.9 Final was released.
In Mar 2013, Hibernate ORM 4.2 Final was released.
In December 2013, Hibernate ORM 4.3.0 Final was released.It features Java Persistence API 2.1.
In September 2015, Hibernate ORM 5.0.2 Final was released. It has improved bootstrapping, hibernate-java8, hibernate-spatial, Karaf support.
In November 2018, Hibernate ORM 5.1.17 Final was released. This is the final release of the 5.1 series.
In October 2018, Hibernate ORM 5.3 Final was released. It featured Java Persistence API 2.2 inheritance caching.
In December 2018, Hibernate ORM 5.4.0 Final was released.
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.xwd.entity.User" table="user">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="pwd"/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="testaction_*" class="ta" method="{1}">
<result name="success">/list.jsp</result>
</action>
</package>
</struts>
<property name="mappingResources">
<list>
<value>com/xwd/entity/User.hbm.xml</value>
</list>
</property>
</bean>
<bean id="td" class="com.xwd.dao.TestDao">
<property name="sf" ref="sf"></property>
</bean>
<bean id="ts" class="com.xwd.service.TestService">
<property name="testdao" ref="td"></property>
</bean>
<bean id="ta" class="com.xwd.action.TestAction">
<property name="testservice" ref="ts"></property>
</bean>
-
A typical three-tier architecture embodies the idea of MVC(Model, View and Controller), which can relieve developers of the burden and effort of re-establishing solutions to complex problems, facilitate agile development of new requirements, and reduce the development time cost
-
Good scalability. The mainstream technology of SSH has a strong user community to support it, so the framework is highly extensible and pluggable for special applications to avoid most functions that cannot be realized due to technical problems
-
Good maintainability, the business system often has new requirements, the three-tier architecture can minimize the risk of requirement modification due to the reasonable separation of the logic layer and the presentation layer. With the popularity of new technologies or the aging of the system, the system may need to be reconstructed, and the success rate of SSH architecture reconstruction is much higher than other architectures
-
Excellent decoupling, few software products demand is completely right from the start of a fixed customer software requirements, is with the deepening of the software development process, keep clear, therefore, often meet with software development to a certain extent, because the customer changed demand for software, making the realization of the software had to change the SSH three-tier architecture, control depends on the business logic layer, but not with any specific business logic component coupling, only with the interface coupling;Similarly, the business logic layer relies on the DAO layer and is not coupled to any specific DAO components, but is interface-oriented programming that implements the software in this way, even if one part of the software changes, the rest does not.
1.Hibernate has weaknesses in batch data processing, and it is suitable for Hibernate for simple addition, deletion and modification of single objects, but for batch modification and deletion, it is not suitable for Hibernate, which is also a weakness of the OR framework; to use the specific optimization mechanism of the database Is not suitable for use Improper application of Hibernate optimization strategy will cause a lot of resource consumption.
2.Spring relies on reflection, which affects performance. Reflection requires several times more code instructions than pure code.And Spring over relies on Design Patterns.And there are many configurations. XML configuration management is difficult and complicated. With the accumulation of time, all kinds of XML configurations appear in the system, which cannot be maintained by unified management. Updating and upgrading the application configuration must be re launched. Test efficiency starts slowly with the increase of configuration items.
The use of the framework can greatly shorten the development cycle of large-scale systems and improve the development quality. For traditional Java programming, comparing the object-oriented technology based on the class library, the framework has sealed these codes for us. In the development process, as long as we can call these already written classes or interfaces to implement the methods, or rewrite the methods to make them Our work services can save our development cycle. Make the work more efficient and orderly.
Application framework is more inclined to software reuse for professional fields. With the continuous development of software industry, various systems become more complex, and the fields involved are more and more broad. If every new system is received and re developed, it will be a very long process, reducing the work efficiency. If the staff in the team write their own, due to the different working styles of each person and the different ways of writing code, the project will become disorderly, and if there is a problem in the system, it is even more difficult to maintain it again. Therefore, SSH framework can make developers write programs as consistent as possible, which can reduce the maintenance complexity caused by different working habits.
- https://www.cnblogs.com/xiaobaizhiqian/p/7616453.html
- https://www.codejava.net/frameworks/struts/introduction-to-struts-2-framework#WhatisStruts
- https://www.techopedia.com/definition/3984/struts-framework
- En.wikipedia.org. 2020. Hibernate (Framework). [online] Available at: https://en.wikipedia.org/wiki/Hibernate_(framework) [Accessed 21 May 2020].
- https://baike.baidu.com/item/ssh%E6%A1%86%E6%9E%B6/8882453?fr=aladdin
- https://blog.csdn.net/ycclydy/article/details/80451571
- https://www.cnblogs.com/hoobey/p/6100937.html
- https://blog.csdn.net/qq_28143647/article/details/79459004
- https://www.jianshu.com/p/69030f8f5437
- https://blog.csdn.net/sinat_37001576/java/article/details/80089526
Jifeng Li,Jiawei Du,Bowei Wang finished the work of SSH.
The following is our group's contribution to this wiki:
1.SSH framework
2.The specific description of the core composition of Spring
3.The history of Struts*
4.The features of Struts
5.The history of hibernate
6.The sample code of SSH framework
Song Zekai,Guan Hongzheng,Zhang Yaqing and Zhu Hongrui finished the work of SSH.
Wang Ruilong,Zhao Jiale and Zhou Jingkai finished the work of Gjango.
The following is the specific division of labor:
Song Zekai:
-
The business process of SSH framework
-
Part of SSH = Struts + Spring + Hibernate:
Struts: What is Struts, The core composition of Struts, Why use Struts
Spring: What is Spring, The core composition of Spring, Why use Spring
Hibernate: What is Hibernate, The core composition of Hibernate
Guan Hongzheng:
-
The advantages of SSH framework
-
On page Compare Django and SSH:A comparison between the SSH framework and the Django framework
Zhang Yaqing:
SSH framework
Zhu Hongrui:
The significance of SSH framework
