Spring学习笔记之Spring MVC体系学习(一)

1、Spring MVC应用一般包括以下步骤:
1. 配置web.xml,指定业务层对应的Spring配置文件,定义DispatcherServlet;
2. 编写处理请求的控制器;
3. 编写视图对象;
4. 配置Springl MVC的配置文件,使控制器、视图解析器生效。
2、配置DispatcherServlet,截获特定的URL请求web配置示例:

<context-param>
    <param-value>contextConfigLocationparam-value>
    <param-value>classpath:/conf/applicationContext.xmlparam-value>
context-param>
<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    listen-class>
listener>

<servlet>
    <servlet-name>servletNameservlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    servlet-class>
    <load-on-startup>1load-on-startup>
servlet>

<servlet-mapping>
    <servlet-name>servletNameservlet-name>
    <url-pattern>*.htmlurl-pattern>
servlet-mapping>

3、简单web层Spring配置示例:

param>
    <param-name>contextConfigLocationparam-name>
    <param-value>
        /WEB-INF/spring/webApplicationContext.xml
    param-value>
param>

你可能感兴趣的:(spring)