zoukankan      html  css  js  c++  java
  • spring配置文件和spring mvc配置文件的区别

    Question:

    • Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework?
    • Will the properties files declared in applicationContext.xml be available to DispatcherServlet?
    • On a related note, why do I need a *-servlet.xml at all? Why is applicationContext.xmlalone insufficient?

    Answer:

    Spring lets you define multiple contexts in a parent-child hierarchy.

    The applicationContext.xml defines the beans for the "root webapp context", i.e. the context associated with the webapp.

    The spring-servlet.xml (or whatever else you call it) defines the beans for one servlet's app context. There can be many of these in a webapp, one per Spring servlet (e.g. spring1-servlet.xmlfor servlet spring1spring2-servlet.xml for servlet spring2).

    Beans in spring-servlet.xml can reference beans in applicationContext.xml, but not vice versa.

    All Spring MVC controllers must go in the spring-servlet.xml context.

    In most simple cases, the applicationContext.xml context is unnecessary. It is generally used to contain beans that are shared between all servlets in a webapp. If you only have one servlet, then there's not really much point, unless you have a specific use for it.

  • 相关阅读:
    站立会议 第十天
    站立会议 第十天
    找水王
    购买《哈利波特》书籍
    站立会议第三天
    站立会议第二天
    冲刺会议第一天
    补发《超级迷宫》站立会议五
    补发《超级迷宫》站立会议四
    课堂练习之求1到N之间的数里面含有1的个数
  • 原文地址:https://www.cnblogs.com/zhouj-happy/p/6088891.html
Copyright © 2011-2022 走看看