• Spring_在 WEB 应用中使用


    1. Spring 如何在 WEB 应用中使用 ?

    1). 需要额外加入的 jar 包:

    spring-web-4.0.0.RELEASE.jar
    spring-webmvc-4.0.0.RELEASE.jar

    2). Spring 的配置文件, 没有什么不同

    3). 如何创建 IOC 容器 ?

    ①. 非 WEB 应用在 main 方法中直接创建
    ②. 应该在 WEB 应用被服务器加载时就创建 IOC 容器:

    在 ServletContextListener#contextInitialized(ServletContextEvent sce) 方法中创建 IOC 容器.

    ③. 在 WEB 应用的其他组件中如何来访问 IOC 容器呢 ?

    在 ServletContextListener#contextInitialized(ServletContextEvent sce) 方法中创建 IOC 容器后, 可以把其放在
    ServletContext(即 application 域)的一个属性中.

    ④. 实际上, Spring 配置文件的名字和位置应该也是可配置的! 将其配置到当前 WEB 应用的初始化参数中较为合适.

    4). 在 WEB 环境下使用 Spring

    ①. 需要额外加入的 jar 包:

    spring-web-4.0.0.RELEASE.jar
    spring-webmvc-4.0.0.RELEASE.jar

    ②. Spring 的配置文件, 和非 WEB 环境没有什么不同

    ③. 需要在 web.xml 文件中加入如下配置:

    <!-- 配置 Spring 配置文件的名称和位置 -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

    <!-- 启动 IOC 容器的 ServletContextListener -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    All that work will definitely pay off
  • 相关阅读:
    SKAction类
    SpriteKit所有的类
    Reachability下载地址
    IOS学习教程
    SpriteKit游戏开发
    APP开发者到期续费说明
    Unique Paths
    Letter Combinations of a Phone Number
    Reverse Nodes in k-Group
    Remove Nth Node From End of List
  • 原文地址:https://www.cnblogs.com/afangfang/p/12992799.html
Copyright © 2020-2023  润新知