初始化容器
来源:互联网 发布:win7安装apache 编辑:程序博客网 时间:2024/06/07 01:25
WebApplicationInitializer是Spring提供用来配置Servlet 3.0+配置的接口,从而实现了替代web.xml的作用。
实现此接口将会自动被SpringServletContainerInitializer(用来启动Servlet3.0容器)获取到。
package com.lebron.springmvc;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.ServletRegistration.Dynamic;import org.springframework.web.WebApplicationInitializer;import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;import org.springframework.web.servlet.DispatcherServlet;public class WebInitializer implements WebApplicationInitializer{@Overridepublic void onStartup(ServletContext servletContext) throws ServletException {AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();ctx.register(MyMvcConfig.class); //加载springMVC配置ctx.setServletContext(servletContext);//注册springMVC的DispatcherServletDynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/");servlet.setLoadOnStartup(1);//servlet.setAsyncSupported(true); //开启异步方法支持}}
阅读全文
0 0
- 容器初始化
- 容器 初始化
- 初始化容器
- spring初始化容器
- 容器ArrayList的初始化.
- 静态容器变量初始化
- 容器通过数组初始化
- Spring初始化容器
- Spring初始化容器
- Spring获得初始化容器
- 顺序容器:初始化
- vector顺序容器初始化
- Spring容器初始化
- spring容器重复初始化
- Ioc容器初始化过程
- springmvc容器初始化
- IOC_bean容器初始化
- Ioc容器初始化
- phpMyAdmin
- 数据抽取方式和各方式特点
- spring中异步配置
- Z字形编排
- rxjava+Retrofit+okhttp 实战网络请求
- 初始化容器
- [LeetCode]127. Word Ladder 深入浅出讲解和代码示例
- 记:第一次使用Nginx搭建图片服务器
- 一起做RGB-D SLAM(5)
- Android BottomNavigationView与ViewPager+fragment结合实现material Tab标准效果
- 最长公共子序列(LCS)
- JAVA图片压缩
- LINUX(CENTOS7.X)SVN部署文档
- Lua数据类型