zoukankan      html  css  js  c++  java
  • SpringMVC框架介绍

      1、 SpringMVC通过一套MVC注解,让POJO成为处理请求的控制器,而无须实现任何接口。

        2、支持REST风格的URL请求。

        3、采用了松散耦合可插拔组件结构,比其他MVC框架更具扩展性和灵活性。 

        4、 配置web.xml文件

    4.1 配置DispatcherServlet:默认加载/WEB-INF/<servletName-servlet>.xml的Spring配置文件,启动WEB层的Spring容器。可以通过contextConfigLocation初始化参数自定义配置文件的位置和名称。

    <servlet>
    <servlet-name>springMvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- Spring MVC相关配置文件路径 -->
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/spring-*.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>springMvc</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping> 

    4.2  配置自动扫描的包

    <!-- 扫描业务组件,让spring不扫描带有@Service注解的类(留在root-context.xml中扫描@Service注解的类),防止事务失效 -->
    <context:component-scan base-package="com.hsmdata.qualityinspect">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> 
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
    </context:component-scan>

     4.3 配置视图解析器

    <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/"></property>
    <property name="suffix" value=".jsp"></property>
    </bean>
      

  • 相关阅读:
    HashTable、HashSet和Dictionary的区别
    CCF_ 201312-3_最大的矩形
    CCF_ 201312-2_ISBN号码
    CCF_201312-1_出现次数最多的数
    CCF_ 201509-2_日期计算
    CCF_ 201512-3_画图
    CCF_ 201512-2_消除类游戏
    CCF_ 201409-2_画图
    CCF_201409-1_相邻数对
    CCF_ 201412-1_门禁系统
  • 原文地址:https://www.cnblogs.com/esther-qing/p/5899762.html
Copyright © 2011-2022 走看看