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>

    参考:

  • 相关阅读:
    js 报Unexpected token }
    c# 预览服务器文件
    js下载文件并修改文件名称
    js 自定义右键
    js 加载图片
    随笔1
    随笔
    php curl 发送post请求带参数
    laravel 数据库事务
    an't connect to local MySQL server through socket '/tmp/mysql.sock'
  • 原文地址:https://www.cnblogs.com/happyflyingpig/p/8452222.html
Copyright © 2011-2022 走看看