zoukankan      html  css  js  c++  java
  • Spring 小知识点

    一、引入配置文件的方式:

    方式一:

    <context:property-placeholder location="classpath:jdbc.properties,classpath:dubbo.properties" />

     方式二:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:jdbc.properties</value>
                <value>classpath*:dubbo.properties</value>
            </list>
        </property>
        <property name="fileEncoding" value="UTF-8" />
        <property name= "ignoreResourceNotFound" value="false"/>
    </bean>

    方式三:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:jdbc.properties" />
    </bean>

     二、SpringMVC DispatcherServlet 在web.xml中的配置

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-servlet-config.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    如果使用如上配置,Spring Web MVC框架将加载“classpath:spring-servlet-config.xml”来进行初始化上下文而不是“/WEB-INF/[servlet名字]-servlet.xml”

    三、web.xml配置上下文关系

    <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>
              classpath:spring-common-config.xml,
              classpath:spring-budget-config.xml
          </param-value>
    </context-param>
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    参考:

  • 相关阅读:
    在ConcurrentModificationException异常上的联想
    记录一下自己爬虎牙LOL主播的爬虫思路
    ajax解决跨域问题
    解决多线程下数据库操作问题
    浅谈时间复杂度
    想一下,最大公约数怎么求
    IO流与IO缓冲
    循环移位
    3Sum探讨(Java)
    Two Sum(两个数的相加)
  • 原文地址:https://www.cnblogs.com/happyflyingpig/p/8452222.html
Copyright © 2011-2022 走看看