Spring MVC

一. 簡介

  1. SpringMVC的HelloWorld程序
    配置web.xml前端

    <web-app>
    <display-name>Archetype Created Web Application</display-name>
    
    <!--初始化spring時,加載springcontext.xml配置文件-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:springcontext.xml</param-value>
    </context-param>
    
    <!--配置監聽器,容器啓動時加載sping容器-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <!--配置servlet,攔截全部的請求,走DispatcherServlet-->
    <servlet>
        <servlet-name>app1</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!--初始化參數,前端控制器加載配置文件-->
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>app1</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    </web-app>

    配置 springmvc.xmlweb

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       https://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       https://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
    <!--開啓註解掃描-->
    <context:component-scan base-package="cn.guet"/>
    
    <!--視圖解析器-->
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    
    <!--開啓spingmvc註解支持-->
    <mvc:annotation-driven/>
    </beans>
  2. Springmvc執行流程
    spring

  3. @RequestMapping:指定請求的URLspring-mvc

  4. 有序列表項 一
  5. 有序列表項 二
  6. 有序列表項 三
  7. 有序列表項 一
  8. 有序列表項 二
  9. 有序列表項 三
  10. 有序列表項 三mvc

二. 分級標題

  1. 有序列表項 一
  2. 有序列表項 二
  3. 有序列表項 三
  4. 有序列表項 一
  5. 有序列表項 二
  6. 有序列表項 三
  7. 有序列表項 一
  8. 有序列表項 二
  9. 有序列表項 三
  10. 有序列表項 三

三. 外連接

  1. 有序列表項 一
  2. 有序列表項 二
  3. 有序列表項 三
  4. 有序列表項 一
  5. 有序列表項 二
  6. 有序列表項 三
  7. 有序列表項 一
  8. 有序列表項 二
  9. 有序列表項 三
  10. 有序列表項 三

四. 無序列表

  1. 有序列表項 一
  2. 有序列表項 二
  3. 有序列表項 三
  4. 有序列表項 一
  5. 有序列表項 二
  6. 有序列表項 三
  7. 有序列表項 一
  8. 有序列表項 二
  9. 有序列表項 三
  10. 有序列表項 三

五. 有序列表

  1. 有序列表項 一
  2. 有序列表項 二
  3. 有序列表項 三
  4. 有序列表項 一
  5. 有序列表項 二
  6. 有序列表項 三
  7. 有序列表項 一
  8. 有序列表項 二
  9. 有序列表項 三
  10. 有序列表項 三
相關文章
相關標籤/搜索