zoukankan      html  css  js  c++  java
  • Spring配置文件笔记

    启动服务器:
        <!-- Spring ApplicationContext配置文件的路径,可使用通配符. -->
        <!-- 多个路径用,号分隔此参数用于后面的Spring Context Loader -->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/applicationContext.xml</param-value>
        </context-param>
        <!-- Spring初始化容器类. -->
        <!-- 取配置文件里面定义的参数contextConfigLocation-->
        <!-- 若没有定义参数,则默认读取applicationContext.xml. -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    以上内容会初始化容器类,实例化所有交给Spring的类。
    
    用户请求过滤类:
       <!-- 字符编码过滤. -->
        <filter>
            <filter-name>encodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>encodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    用户请求分发类: <!-- Spring分发的类,所有以.html结尾的页面均对应classpath*:dispatcher-servlet.xml配置文件. --> <servlet> <servlet-name>dispatcher-servlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher-servlet</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> 其他辅助类: <!-- Spring 刷新Introspector防止内存泄露 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- spring Security获得session生存周期事件 --> <listener> <listener-class> org.springframework.security.web.session.HttpSessionEventPublisher </listener-class> </listener>

      

    路慢慢其休远羲,吾将上下而求所
  • 相关阅读:
    在服务器上搭建java环境
    往Android studio中导入类库文件
    Android异步任务AsyncTask
    搭建java环境
    使用安卓实现一个二维码扫描功能(基于Android Studio)
    Android中的runOnUiThread
    网络基础
    Android使用URL访问网络资源
    21天学通VC++
    cometd(转)
  • 原文地址:https://www.cnblogs.com/garinzhang/p/2690543.html
Copyright © 2011-2022 走看看