Difference between applicationContext.xml and spring-servlet.xml in Spring Framework
Question:
- Are
applicationContext.xml
andspring-servlet.xml
related anyhow in Spring Framework? - Will the properties files declared in
applicationContext.xml
be available toDispatcherServlet
? - On a related note, why do I need a
*-servlet.xml
at all? Why isapplicationContext.xml
alone 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.xml
for servlet spring1
, spring2-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.
Difference between applicationContext.xml and spring-servlet.xml in Spring Framework的更多相关文章
- Spring MVC 零配置 / Spring MVC JavaConfig
1. Spring MVC的核心就是DispatcherServlet类,Spring MVC处理请求的流程如下图所示: 2. Spring MVC中典型的上下文层次 当我们初始化一个Dispatch ...
- The difference between applicationContext.xml in Spring and xxx-servlet.xml in SpringMVC
一直搞不明白两者的区别.如果使用了SpringMVC,事实上,bean的配置完全可以在xxx-servlet.xml中进行配置.为什么需要applicationContext.xml?一定必须? 因为 ...
- Spring中,applicationContext.xml 配置文件在web.xml中的配置详解
一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> < ...
- Spring MVC web.xml+servlet.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " ...
- spring web.xml 难点配置总结
web.xml web.xml是所有web项目的根源,没有它,任何web项目都启动不了,所以有必要了解相关的配置. ContextLoderListener,ContextLoaderServlet, ...
- Spring 通过XML配置文件以及通过注解形式来AOP 来实现前置,环绕,异常通知,返回后通知,后通知
本节主要内容: 一.Spring 通过XML配置文件形式来AOP 来实现前置,环绕,异常通知 1. Spring AOP 前置通知 XML配置使用案例 2. Spring AOP ...
- spring web.xml 难点配置总结【转】
web.xml web.xml是所有web项目的根源,没有它,任何web项目都启动不了,所以有必要了解相关的配置. ContextLoderListener,ContextLoaderServlet, ...
- Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc.xml] cannot be opene
Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc. ...
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
使用web.xml方式加载Spring时,获取Spring context的两种方式: 1.servlet方式加载时: [web.xml] <servlet> <servlet-na ...
随机推荐
- MVC4中的Display Mode简介
本文地址:http://www.cnblogs.com/egger/p/3400076.html 欢迎转载 ,请保留此链接๑•́ ₃•̀๑! 今天学习MVC4时,看到一个不错的特性"vie ...
- 【USB多路电源】---需求分析方案制定
需求描述: USB接口输入5V,分别输出±5V,100mA; 3.3V,100mA: 1.2V,500mA:四路电源.同时可给锂电池充电,在移除USB输入时锂电池能供电. 分析: 首先考虑需要一个充电 ...
- Wifite v2 is now available
Wifite v2 is now available What's new in this version: support for cracking WPS-encrypted networks ( ...
- 初识selendroid
Testerhome社区的lihuazhang对selendroid官网的部分内容进行了翻译和讲解. 以下内容均摘自lihuazhang.感谢lihuazhang的讲解.原文地址:https://gi ...
- log4net.config 单独文件
使用的命名空间下添加 [assembly: log4net.Config.DOMConfigurator(ConfigFile = "log4net.config", Watch ...
- C语言基础--二维数组
二维数组概念: 数组中的每一个元素又是一个数组, 那么这个数组就称之为二维数组,二维数组是特殊的一维数组. 二维数组格式: 元素类型 数组名称[一维数组的个数][每个一维数组的元素个数]; 元素类型 ...
- 使用python 提取网页的特定数据转
http://blog.csdn.net/nwpulei/article/details/7272832
- find_in_set()
$where[]="find_in_set('".$grades."',a.grades)";
- hdu 2087
ps:感觉就是字符串处理...好像没什么好讲的...直接上代码 代码: #include "stdio.h" #include "string.h" ]; ]; ...
- DIY FSK RFID Reader
This page describes the construction of an RFID reader using only an Arduino (Nano 3.0 was tested, b ...