spring + springMVC knowledge summary

1. What is spring? What spring's two core technologies yes.

spring是一个开源的,轻量级的控制反转IoC和面向切面AOP的容器框架
IOC(控制反转)和DI(依赖注入)
AOP(面向切面编程)是面向对象编程的一个补充

2, Sring excellent characteristics:

Excellent characteristics of Spring

[1]非侵入式:基于Spring开发的应用中的对象可以不依赖于Spring的API
[2]依赖注入:DI——Dependency Injection,反转控制(IOC)最经典的实现。
[3]面向切面编程:Aspect Oriented Programming——AOP
[4]容器:Spring是一个容器,因为它包含并且管理应用对象的生命周期
[5]组件化:Spring实现了使用简单的组件配置组合成一个复杂的应用。在 Spring 中可以使用XML和Java注解组合这些对象。
[6]一站式:在IOC和AOP的基础上可以整合各种企业应用的开源框架和优秀的第三方类库(实际上Spring 自身也提供了表述层的SpringMVC和持久层的Spring JDBC)。

3. What are the main module Spring framework?

Core container, data access / integration ,, Web, AOP (Aspect Oriented Programming), tools, modules and test message.
Here Insert Picture Description

4, what is the ioc, what does it do?

应用本身不负责创建依赖对象,把它交给外部容器的过程
作用:解耦
(1)xml配置文件(2)dom4j解析(3)工厂设计模式(4)反射

5. What is DI, DI and ioc difference?

依赖注入,在运行期由外部容器动态地将依赖对象注入组件

6. What is DI, DI and ioc difference?

IOC强调将对象的创建权反转到IOC容器中
DI强调IOC容器将对象的依赖关系动态注入对象之中
DI是IOC具体的实现过程

7, Bean naming?

id、name
可以用name命名,和id一样都是不能有相同值的
name命名可以有多个值,中间用逗号隔开
id命名不可以有多个值

8, Bean scopes?

Singleton、prototype、request、session、globalSession
Singleton:单例模式对象只实例化一次,一个应用只有一个对象的实例。它的作用范围就是整个引用。
prototype:多例模式调用一次bean就实例化一次

9, attribute dependency injection in several ways, namely how to achieve dependency property injection?

1、属性setter方法注入和p命名空间
2、构造参数注入和c命名空间
3、使用注解注入

10, there are three types of data injected:

1、基本类型和String类型
2、其他的bean类型(必须是在spring的配置文件中实现过的bean)
3、复杂类型(集合类型)

11, what is the assembly, the assembly of the options?

由容器负责创建各个对象,并创建各个对象间的依赖关系。
XML显示装配
注解的方式自动装配
java代码装配

12, how to assemble annotation bean | instantiated bean annotations What? | After instantiating bean by annotating what is the name of the bean in the spring container?

@Controller:一般用于表现层的注解。
@Service:一般用于业务层的注解。
@Repository:一般用于持久层的注解。
@Autowired:自动按照类型注入。当使用注解注入属性时,set方法可以省略。它只能注入其他bean类型。
@Resource:按照名称查找找不到时用类型查找。
@Qualifier:在自动按照类型注入的基础之上,再按照Bean的id注入。它在给字段注入时不能独立使用,必须和@Autowire一起使用
@Component:泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
@pointcut:用于指定初始化方法。
接口实现类首字母小写

13, what is the aop, his role?

采取横向抽取机制取代了纵向继承体系的重复代码
作用:在修改原来代码的基础上实现功能的扩展

14, Aop principle?

在运行期通过代理方式向目标类织入增强代码

15, what is the point? Entry point? What is enhanced? What is the goal? What is a proxy? What is the cut?

连接点:实际被增强的业务层方法
切入点:声明将要被增强的方法
增强/通知:要添加给业务方法的代码(增强代码在那个类那个类就是通知)
目标对象:连接点所在的对象
代理:一个类被织入增强后就产生一个结果代理类  生成的动态代理类
								动态代理类=目标对象+增强代码 
织入:将增强的方法添加到链接点的过程
切面:切入点和通知的结合  切入点+通知

Dynamic agent commonly used in two ways

	基于接口的动态代理
		提供者:JDK官方的Proxy类。
		要求:被代理类最少实现一个接口。
	基于子类的动态代理
		提供者:第三方的CGLib,如果报asmxxxx异常,需要导入asm.jar。
		要求:被代理类不能用final修饰的类(最终类)。

16, how to configure the aop through xml configuration?

aop:config
aop:aspect
aop:pointcut
aop:before</aop:aspect></aop:config>

17, how to configure AOP annotations by the way?

<aop:aspectj-autoproxy>在xml中开启注解开关
@Aspect、@pointcut、@before……

18, the difference between the type of enhancement and the AOP?

环绕通知和前置、后置的区别:
	环绕通知能决定是否调用目标方法、能修改返回值
返回通知和后置的区别:
	返回通知可以获取到目标函数的返回值如果目标方法抛异常返回不执行

19, what is characteristic of affairs, things?

一些操作要么全发生要么全不发生
原子性:事务中的操作要么全发生要么全不发生
一致性:事务前后数据的完整性保持一致
隔离性:数据库被多个用户访问此事物不能被其他事物干扰用户之间数据要隔离
持久性:一个事物一旦被提交它对数据的改变就是永久的

20, isolation level things?

Isolation-default:数据库默认
Isolation-read-uncommitted:可能导致脏读不可重复读幻读
Isolation-read-committed:可以防止脏读
Isolation-prepeatable-read:可以防止脏读不可重复读
Isolation-seriablizable:完全服从ACID隔离级别

21. What is the transaction propagation behavior? What is the use?

Whether a new transaction to be started or suspended, or whether the method to be run in a transaction environment

22. What is declarative things?

Spring aop based configuration control, and transaction declaratively annotated
23, how to configure things in xml?
Transaction Manager DataSourceTransactionManager,
transactional advice tx: advice tx: the Attributes tx: Method,
the transaction configuration aop aop: config aop: pointcut aop: Advisor

24, how to configure things in a comment?

Open transaction annotation switch tx: annotation-driven
added @Transactional (propagation = Propagation.REQUIRED, on a transaction to add the class
Isolation = Isolation.DEFAUL)
Propagation: transaction propagation behavior
Isolation: transaction isolation level
readOnly: read-only
rollbackFor: What happened abnormal rollback
NoRollbackFor: abnormal occurrence which does not roll back
rollbackForClassName: according to rollback exception class name

25, spring tomcat how to manage | spring how to configure in web.xml.

ContextLoaderListener

contextConfigLocation
classpath:

org.springframework.web.context.ContextLoaderListener

26, sprinMVC how to manage tomcat | springMVC how to configure in web.xml.

<servlet>
	<servlet-name>
	<servlet-class>
	<init-param>
		<param-name>
		<param-value>
	<load-on-startup>
<servlet-mapping>
	<servlet-name>
	<url-pattern>

27. What is springMvc?

Web层的MVC框架,是一种设计模式设计思想

28, what is mvc, mvc implementation process?

flow chart

The first appreciated that:
1) the request to the client DispatcherServlet
2) by a querying one or more controller DispatcherServlet HandlerMapping, find Controller processing request
. 3) submit requests to DispatcherServlet Controller (also referred Handler)
. 4) Controller service call after the logic processing returns ModelAndView
. 5) one or more queries the DispatcherServlet ViewResoler view resolver, the specified view ModelAndView find
a second understanding:
1. the client sends a request to DispatchServlet
2.DispatchServlet specific query path according to a request Handler
3.HandlerMapping return a HandlerExcutionChain to DispatchServlet
 HandlerExcutionChain: Interceptor Handler and set
4.DispatchServlet call HandlerAdapter adapter
5.HandlerAdapter specific call processing service Handler
6.Handler process ends to return to a particular adapter ModelAndView
ModelAndView: model-> data model, view-> view name
7. the adapter ModelAndView to DispatchServlet
8.DispatchServlet view name to the view resolver ViewResolver
9.ViewResolver return to a particular view DispatchServlet
10. The view renderer
11 to display to users

29, springMvc components which.

处理器映射器、处理器适配器、后端控制器、视图解析器

30, the configuration view resolver What is the role?

The logical view to a physical address parsing
what @RequestMapping that? what's the effect? And property.
@RequestMapping () is a processing request for annotation address mapping,
value = "/ User", Method = RequestMethod.POST

31, parameter types springMvc received what?

简单类型、实体类、数组、Vo、map、默认类型
HttpServletRequest、HttpServletResponse、HttpSession、InputStream、OutputStream、Reader、Writer
@RequestParam绑定参数
@RequestHeader从头部信息绑定参数
@CookieValue从cookie中绑定参数
@PathVariable从URL中绑定参数

32, page data echo of the way?

ModelAndView、Model、map、request

33, the difference between ModelAndView and Model data echo what?

Model: Only used to transmit data, each band must be requested
ModelAndView: view information also contains both a data model, new needs its own
two different API

34, handler method into the annotations on the parameters which were what role.

@RequestParam specified parameters
@PathVariable binding parameters from URL

35, handler method how to return the data format json

Use response returns json
added @ResponseBody method in
configuring a processor adapter

36, springMVC request forwarding and redirection can be achieved, what grammatical structure?

请求转发Forward:/路径地址
重定向Redirect:/路径地。
请求转发:url地址不变,只请求一次,可以获取第一次请求中的参数;只能站内转发。
重定向:url地址变请求两次,不能获取第一次请求中的参数。可以跳转到站外的地址。

37, spirngMVC how to configure Unicode,

jsp pages. 8-coding mode is UTF
formbiandan post is presented in a way
to add a filter inside encoded web.xml

38, springMVC unified idea of ​​exception handling.

dao system, service, controller abnormal are thrown up last referred to by the exception handler front control SpringMVC exception handling

39, <mvc: annotation-driven /> is a shorthand substitute what configuration.

替代了处理器映射器和处理器适配器

40, when mapping configuration DispatcherServlet request to "/", how to achieve the release of static resources?

		<servlet-mapping>
		<servlet-name>default</>
		<url-pattern>*.js</>
<mvc:resources location="/easyUI/" mapping="/easyUI/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:default-servlet-handlet/>

41, what is restful style, restful style development, four verb request indicate what mode of operation?

约定大于规范
Get:查询
POST:添加
PUT:更新
DELETE:删除

42, springMvc is how to achieve submission put and delete requests

在web.xml中配置拦截headerHTTPMethodFile
在表单中写<input type=”hidden”name=”_method”value”delete/put”/>

43, how to make springMVC support file uploads

Type must be submitted file type, submission of POST, add enctype = multipart / form-data arranged in CommonsMultipartResolver springMVC beanName = defaultEncoding form in form, value = UTF-8

44, springMVC support multi-view resolution it?

stand by

Released three original articles · won praise 1 · views 342

Guess you like

Origin blog.csdn.net/weixin_44954939/article/details/97630209