What is the difference between ApplicationContext and WebApplicationContext in Spring MVC?

前端 未结 5 852
迷失自我
迷失自我 2020-11-22 06:53

What is the difference between Application Context and Web Application Context?

I am aware that WebApplicationContext is used for Spring MVC architectur

5条回答
  •  故里飘歌
    2020-11-22 07:18

    The accepted answer is through but there is official explanation on this:

    The WebApplicationContext is an extension of the plain ApplicationContext that has some extra features necessary for web applications. It differs from a normal ApplicationContext in that it is capable of resolving themes (see Using themes), and that it knows which Servlet it is associated with (by having a link to the ServletContext). The WebApplicationContext is bound in the ServletContext, and by using static methods on the RequestContextUtils class you can always look up the WebApplicationContext if you need access to it.

    Cited from Spring web framework reference

    By the way servlet and root context are both webApplicationContext:

    Typical context hierarchy in Spring Web MVC

提交回复
热议问题