zoukankan      html  css  js  c++  java
  • 【Eclipse】springMVC介绍与配置

    SpringMCV介绍:

    Spring MVC是一种基于Java的实现了MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职责解耦,基于请求驱动的,也就是使用请求-响应模型,框架的目的就是帮助我们简化开发

    MVC模式:

    MVC 框架提供了模型-视图-控制的体系结构和可以用来开发灵活、松散耦合的 web 应用程序的组件。MVC 模式导致了应用程序的不同方面(输入逻辑、业务逻辑和 UI 逻辑)的分离,同时提供了在这些元素之间的松散耦合。

    模型Model

        封装了应用程序数据,并且通常它们由 POJO 组成。

    视图View

          主要用于呈现模型数据,并且通常它生成客户端的浏览器可以解释的 HTML 输出。

    控制器Controller

    主要用于处理用户请求,并且构建合适的模型并将其传递到视图呈现。

     

    控制层的框架有哪些:

    Struts 1.0 1.1

    Spring mvc

    Struts2  基于webwork

    从性能上比较:

    Jsp+servlet > struts1.1 > spring mvc > struts2

     创建demo

    1 , 创建一个动态web工程。

    2 , 加入Jar包。

     

    3 ,  web.xml中配置DispatcherServlet

    4 ,  加入Spring MVC的配置文件。

    5 ,编写处下请求的处理器,并标识为处理器。

    6, 编写视图。

    创建配置文件:springmvc.xml 

     2、选择依赖:mvc、contxet、aop(看你需要)

      

    结束:具体内容

    <?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:aop="http://www.springframework.org/schema/aop"
    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/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">

    <!-- 扫描包 -->
    <context:component-scan base-package="com.jd.springmvc"></context:component-scan>

    <!-- 视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"></property>      ---匹配在哪个地址下
    <property name="suffix" value=".jsp"></property>            ---后缀
    </bean>

    </beans>

    在web.xml中配置DispatcherServlet:前端控制器

    <!--注册springmvc -->
    <servlet>
      <servlet-name>bookstore</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:Spring-mvc.xml</param-value>---spring路劲
          </init-param>
          <load-on-startup>1</load-on-startup>----中1的取值1,2,3,4,5代表的是优先级正数的值越小,该servlet的优先级越高,应用启动时就越先加载
    </servlet>
    <servlet-mapping>
        <servlet-name>bookstore</servlet-name>
          <url-pattern>/</url-pattern>---过滤所有请求
    </servlet-mapping>

    学着把生活的苦酒当成饮料一样慢慢品尝, 不论生命经过多少委屈和艰辛, 我们总是以一个朝气蓬勃的面孔, 醒来在每一个早上。
  • 相关阅读:
    Atitit (Sketch Filter)素描滤镜的实现  图像处理  attilax总结v2
    JS设置cookie、读取cookie、删除cookie
    Atitit 图像处理30大经典算法attilax总结
    Atitit数据库层次架构表与知识点 attilax 总结
    Atitit 游戏的通常流程 attilax 总结 基于cocos2d api
    Atitti css transition Animation differ区别
    Atitit 图像清晰度 模糊度 检测 识别 评价算法 源码实现attilax总结
    Atitit 全屏模式的cs桌面客户端软件gui h5解决方案 Kiosk模式
    Atitit 混合叠加俩张图片的处理 图像处理解决方案 javafx blend
    Atitit  rgb yuv  hsv HSL 模式和 HSV(HSB) 图像色彩空间的区别
  • 原文地址:https://www.cnblogs.com/yhm9/p/10502857.html
Copyright © 2011-2022 走看看