zoukankan      html  css  js  c++  java
  • spring配置

    要启动spring容器(我用的版本是spring 3.1),需要在web.xml中进行设置:


    1. 指定spring配置文件的位置
    2. 启动spring容器

    在web.xml进行如下设置

    <!--指定spring的配置文件放在哪里,这个位置是web打包后的位置,
        而不是做项目时候把配置文件放在的resources目录。这一点我也不太理解-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    
    <!-- 通过一个监听器启动spring容器,这个容器使用上面指定的spring配置文件-->
    <listener>
        <listener-class>
                org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    
    

    所以啊,使用spring要首先在web.xml指定spring的配置文件位置,然后通过listener启动容器。
    使用springmvc也类似吧,不过springmvc是通过一个servlet来工作,springmvc在web.xml中配置时候会指定对哪些url起反应,不过springmvc的配置文件无需在web.xml中进行指定,就是通过那个servlet的name-servlet.xml这种形式进行配置,然后放在web.xml那个目录就好了额,这里都是废话。。。

  • 相关阅读:
    leetcode-38.报数
    leetcode-35.搜索插入位置
    leetcode-27.移除元素
    leetcode-26.删除重复数组中的重复项
    leetcode-20.有效的括号
    leetcode-973最接近原点的K个点
    leetcode-14最长公共前缀
    leetcode-13罗马字符转整数
    MFC俄罗斯方块
    leetcode-9.回文数(水仙花数)
  • 原文地址:https://www.cnblogs.com/blbl9527/p/7499260.html
Copyright © 2011-2022 走看看