当前位置: 首页 > news >正文

专业做互联网招聘的网站有哪些网络服务器

专业做互联网招聘的网站有哪些,网络服务器,越南做网站,中国flash网站模板我偶尔会混淆这两个概念-WebApplicationInitializer和ApplicationContextInitializer#xff0c;并希望描述它们中的每一个#xff0c;以便为我自己澄清它们。 我以前在这里写过有关WebApplicationInitializer的博客。 它仅在符合Servlet 3.0规范的Servlet容器中相关#x… 我偶尔会混淆这两个概念-WebApplicationInitializer和ApplicationContextInitializer并希望描述它们中的每一个以便为我自己澄清它们。 我以前在这里写过有关WebApplicationInitializer的博客。 它仅在符合Servlet 3.0规范的Servlet容器中相关并提供了一个挂钩以编程方式配置Servlet上下文。 这将如何帮助您-您可以拥有一个可能没有任何web.xml文件的Web应用程序该文件通常在基于Spring的Web应用程序中用于描述根应用程序上下文以及称为DispatcherServlet的Spring Web前端控制器。 以下是使用WebApplicationInitializer的示例 public class CustomWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {Overrideprotected Class?[] getRootConfigClasses() {return new Class?[]{RootConfiguration.class};}Overrideprotected Class?[] getServletConfigClasses() {return new Class?[]{MvcConfiguration.class};}Overrideprotected String[] getServletMappings() {return new String[]{/};} } 现在什么是ApplicationContextInitializer 。 本质上是在完全创建Spring应用程序上下文之前执行的代码。 使用ApplicationContextInitializer的一个好用例是按照以下方式以编程方式设置Spring环境配置文件 public class DemoApplicationContextInitializer implements ApplicationContextInitializerConfigurableApplicationContext {Overridepublic void initialize(ConfigurableApplicationContext ac) {ConfigurableEnvironment appEnvironment ac.getEnvironment();appEnvironment.addActiveProfile(demo);} } 如果您有一个基于Spring-Boot的应用程序那么注册ApplicationContextInitializer非常简单 Configuration EnableAutoConfiguration ComponentScan public class SampleWebApplication {public static void main(String[] args) {new SpringApplicationBuilder(SampleWebApplication.class).initializers(new DemoApplicationContextInitializer()).run(args);} } 但是对于非Spring-Boot Spring应用程序而言它有些棘手如果它是web.xml的编程配置则该配置遵循以下原则 public class CustomWebAppInitializer implements WebApplicationInitializer {Overridepublic void onStartup(ServletContext container) {AnnotationConfigWebApplicationContext rootContext new AnnotationConfigWebApplicationContext();rootContext.register(RootConfiguration.class);ContextLoaderListener contextLoaderListener new ContextLoaderListener(rootContext);container.addListener(contextLoaderListener);container.setInitParameter(contextInitializerClasses, mvctest.web.DemoApplicationContextInitializer);AnnotationConfigWebApplicationContext webContext new AnnotationConfigWebApplicationContext();webContext.register(MvcConfiguration.class);DispatcherServlet dispatcherServlet new DispatcherServlet(webContext);ServletRegistration.Dynamic dispatcher container.addServlet(dispatcher, dispatcherServlet);dispatcher.addMapping(/);} } 如果它是正常的web.xml配置则可以通过以下方式指定初始化程序 context-paramparam-namecontextInitializerClasses/param-nameparam-valuecom.myapp.spring.SpringContextProfileInit/param-value /context-paramlistenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener 因此可以得出结论除了Initializer后缀之外WebApplicationInitializer和ApplicationContextInitializer都具有完全不同的目的。 Servlet容器在Web应用程序启动时使用WebApplicationInitializer并提供了一种以编程方式创建Web应用程序的方法替换web.xml文件而ApplicationContextInitializer提供了一个钩子用于在完全创建Spring应用程序上下文之前对其进行配置。 翻译自: https://www.javacodegeeks.com/2014/10/spring-webapplicationinitializer-and-applicationcontextinitializer-confusion.html
http://www.pierceye.com/news/233208/

相关文章:

  • 海口网站建设呢做健身推广网站
  • 哈尔滨网站搜索优化苏州网站建设主页
  • 35互联网站建设怎么样设计工作室宣传文案
  • php做的网站如何该样式云服务器产品介绍
  • 个人网站建设论文绪论上海it公司有哪些
  • 建设网站推广广告图郑州妇科医院哪家好些
  • 自己网站wordpress主题怎么wordpress 功能块
  • 网站制作咨询电话网站建设技术员分为前端 后端
  • 9元建站节建材 团购 网站怎么做
  • 河南城乡住房和建设厅网站公司微信网站建设方案模板下载
  • 西安制作公司网站的公司邯郸市三建建筑公司网址
  • 网站建设工作目标惠州网站网站建设
  • 就业创业网站建设微信app下载安装旧版本
  • 沧州网站备案年栾洪全单页做网站教程
  • 网站开发的疑虑做门窗投标网站
  • 小型企业门户网站源码如何使用wordpress制作网站
  • 深圳网络营销网站建设北京建设网证书查询平台官网
  • 广播电台网站建设板块自己做网站导航页
  • 网站ui设计兼职android开发工具箱
  • 网站导航网站开发建设公司自己的网站
  • 网站建设专业的公司哪家好优秀创意网站
  • wordpress 文件目录seo网站关键词排名软件
  • 网站管理员功能wordpress增加购物车
  • 外国广告公司网站一个wordpress的爱好者
  • 锦溪网站建设怎么查看网站是否被收录
  • 网站建设感悟平面设计在哪里接单
  • 网站建设中html网页软件开发定制外包服务商
  • 山东seo网站推广河南定制网站建设企业
  • 网站建设文献文档单产品网站建设
  • 唐山网站建设自主开发宁波北仑做公司网站