Spring MVC知识要点

时间:2014-02-16 14:10:10   收藏:0   阅读:330

一.web.xml

1.ContextLoaderListener

职责:加载顶层 WebApplicationContext.

WebApplicationContext主要用于提供应用所使用的所有中间层服务,包括数据源,DAO,Service,都在其中注册。默认配置文件--/WEB-INF/applicationContex.xml

当需要多个配置文件时,可以通过contextConfigLocation的配置参数来设置。

(可以参考org.springframework.web.context.ContextLoader类的javadoc来进行param-value值的设置)

bubuko.com,布布扣
<!-- 配置文件地址 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext*.xml</param-value>
    </context-param>    
<!-- Spring 启动监听 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
bubuko.com,布布扣

 

2.DispatcherServlet

Front Controller,负责Web请求的处理。使用一个外部化的配置文件XXX-serlvet.xml,该配置文件里定义了handlerMapping,viewResolver等。

bubuko.com,布布扣
    <!-- SpringMVC 控制器 -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatch-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
bubuko.com,布布扣

 

3.handlerMapping

 

 

 

 

bubuko.com,布布扣

原文:http://www.cnblogs.com/zhyxBlog/p/3550852.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!