Explanation of SSM framework

 1. What does spring do

1. According to the core function of Spring, IOC (or DI)-dependency injection, it can be seen that Spring mainly helps you manage your class instances, that is to say, Spring is a container. Your configuration class in the configuration file assembles your classes and handles dependencies between instances of each class. The life cycle of objects is managed by Spring. The most intuitive feeling to us is that you don't need to create an object yourself. When you need an object, just go to the spring container to get it.

2. Another important function of Spring is AOP - Aspect-Oriented Programming, which mainly provides specific services to applications, such as log services, transaction services, etc. With this, you can customize the service through configuration without writing log management, transaction processing, etc. code in the class at the beginning. This improves code simplicity and component reusability.

3. Spring provides a platform for the integration of various frameworks, so that Struts, Hibernate or ibatis can be integrated through Spring.

2. What does spring do

Spring is a powerful framework that solves many common problems in J2EE development. Spring provides a consistent approach to managing business objects and encourages the injection of good habits of programming to interfaces rather than classes. Spring's architectural foundation is based on the Inversion of Control container using JavaBean properties. However, this is only part of the complete picture: Spring is unique in using the IoC container as a complete solution that focuses on all architectural layers. Spring provides the only data access abstraction, including a simple and efficient JDBC framework, which greatly improves efficiency and reduces possible errors. Spring's data access architecture also integrates with Hibernate and other O/R mapping solutions. Spring also provides the only transaction management abstraction that provides a consistent programming model across various underlying transaction management technologies such as JTA or JDBC transactions. Spring provides an AOP framework written in the standard Java language, which provides declarative transaction management and other enterprise transactions for POJOs -- if you need them -- as well as implementing your own aspects. This framework is powerful enough to allow applications to throw away the complexities of EJBs while enjoying the key services associated with traditional EJBs. Spring also provides a powerful and flexible MVC web framework that can be integrated with the IoC container.

1. What is SpringMvc?

SpringMvc is a module of spring. A framework based on MVC does not require an intermediate integration layer to integrate 

 What is MVC? The application of mvc under b/s:

First request to send a request request to C (control receives user requests and responds to users), then the controller goes to the M model (pojo, action, service, dao) layer to process the results and return to the controller. The controller must go through view rendering and finally return to the terminal (response)

 

 In the b/s system, the model cannot directly fill the data into the view or should it return to the controller 

MVC is a design pattern is a solution for developing programs

 

Front Controller DispatcherServlet 

Handle the execution chain HandlerExecutionChian 

Handler Mapper HandlerMapping

处理器适配器 HandlerAdapter 去执行Handler

前端控制器 DispatcherServlet 请求执行Handler 处理完  返回 ModelAndView (模型和视图的结合体) 前端控制器接收到ModelAndView后请求视图解析器 返回view 前端控制器将视图进行渲染

SpringMvc整个的执行流程:

1、发起请求到前端控制器(DispatcherServlet )

2、前端控制器请求HandlerMapping查找Handler(可以根据xml、注解进行查找)

3、处理器映射器HandlerMapping向前端控制器DispatcherServlet 返回Handler

4、前端控制器DispatcherServlet 调用处理器适配器HandlerAdapter 执行Handler

5、处理器适配器HandlerAdapter 执行Handler

6、Handler执行完给处理器适配器返回ModelAndView

7、处理器适配器向前端控制器返回ModelAndView (ModelAndView 是SpringMvc的底层对象 包括model和view)

8、前端控制器请求视图解析器去解析视图

  根据逻辑视图名解析成真正的视图(jsp)

9、视图解析器向前端控制器返回view

10、前端控制器进行视图渲染

  视图渲染将模型数据(模型数据在ModelAndView对象中)填充到request域

11、前端控制器向用户响应结果

组件:

1、前端控制器 DispatcherServlet(不需要程序员开发)

  作用:接收请求、响应结果 相当于转发器

  有了DispatcherServlet 就减少了其它组件之间的耦合度

2、处理器映射器HandlerMapping(不需要程序员开发)

  作用:根据请求的URL来查找Handler

3、处理器适配器HandlerAdapter

  作用:按照特定的规则(HandlerAdapter要求的规则)去执行Handler

  注意:在编写Handler的时候要按照HandlerAdapter要求的规则去编写,这样适配器HandlerAdapter才可以正确的去执行Handler

4、处理器Handler(需要程序员开发

5、视图解析器 View Resolver(不需要程序员开发)

  作用:进行视图的解析 根据视图逻辑名解析成真正的视图(view)

6、视图View(需要程序员开发jsp

  View是一个接口, 它的实现类支持不同的视图类型(jsp,freemarker,pdf。。。)

什么是Mybatis?

mybatis是一个优秀的基于java的持久层框架,它内部封装了jdbc,使开发者只需要关注sql语句本身,而不需要花费精力去处理加载驱动、创建连接、创建statement等繁杂的过程。

mybatis通过xml或注解的方式将要执行的各种statement配置起来,并通过java对象和statement中sql的动态参数进行映射生成最终执行的sql语句,最后由mybatis框架执行sql并将结果映射为java对象并返回。


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325523440&siteId=291194637