zoukankan      html  css  js  c++  java
  • Spring框架——day01原理图和基本配置

    Spring框架-原理图和基本配置 

    一,springMVC流程图 

     

      组件分析:
    	1;前端控制器(只需配置) 作用:只负责分发请求。可以很好的对其他组件进行解耦合。
    	2;处理器映射器(只需配置)
    	3;处理器适配器(只需配置)
    	4;处理器(需要开发)
    	5;视图解析器(只需配置)
    	6;视图(需要开发)
    二,SpringMVC快速入门

      1.创建maven工程
      2.导入springmvc依赖及servlet-api
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.3.12.RELEASE</version>
      </dependency>
      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
      </dependency>
    3.在web.xml配置前端控制器
      <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
      </servlet-mapping>
    4.创建Controller
      @org.springframework.stereotype.
      Controller("/test")
        public class TestController implements Controller {
                @Override public ModelAndView handleRequest(HttpServletRequest request,
                      HttpServletResponse response) throws Exception {
          System.out.println("Hello,SpringMVC!");
          return null; }
          }
    5.创建springmvc配置文件
    在WEB-INF下创建springmvc-servlet.xml
    <?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:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <context:component-scan base-package="com.lanou.controller"/>
    </beans>








  • 相关阅读:
    SQL的四种连接(内连接,外连接)
    MySQL连表操作之一对多
    [转]Mysql连表之多对多
    Hibernate笔记二
    Hibernate框架报错:org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.mikey.hibernate.domain.Person.pid
    Hibernate框架:org.hibernate.exception.SQLGrammarException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java92)
    [转]网络编程三要素
    Hibernate笔记一
    JavaScript高级特征之面向对象笔记
    Myeclipse创建HTML文件中文显示乱码问题
  • 原文地址:https://www.cnblogs.com/memo-song/p/9157308.html
Copyright © 2011-2022 走看看