首页 > 编程语言 > 详细

Spring MVC体系

时间:2019-03-01 10:16:27      阅读:201      评论:0      收藏:0      [点我收藏+]

框架搭建

技术分享图片

    web.xml配置

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
 3   <display-name>springMVC</display-name>
 4   <servlet>
 5     <servlet-name>springmvc</servlet-name>
 6     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 7     <init-param>
 8       <param-name>contextConfigLocation</param-name>
 9       <param-value>classpath:springmvc-servlet.xml</param-value>
10     </init-param>
11     <load-on-startup>1</load-on-startup>
12   </servlet>
13   <servlet-mapping>
14     <servlet-name>springmvc</servlet-name>
15     <url-pattern>/</url-pattern>
16   </servlet-mapping>
17 </web-app>

  Spring MVC配置文件

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:mvc="http://www.springframework.org/schema/mvc"
 5     xmlns:p="http://www.springframework.org/schema/p"
 6     xmlns:context="http://www.springframework.org/schema/context"
 7     xsi:schemaLocation="
 8         http://www.springframework.org/schema/beans
 9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://www.springframework.org/schema/context
11         http://www.springframework.org/schema/context/spring-context.xsd
12         http://www.springframework.org/schema/mvc
13         http://www.springframework.org/schema/mvc/spring-mvc.xsd">
14         <!-- 配置处理单映射 HandlerMapping -->
15      <!--<bean name="/index.html" class="cn.smbms.controller.IndexController"/>  -->  
16     
17         <!-- 多个映射 注解方式处理 -->
18         <mvc:annotation-driven/>      
19         <context:component-scan base - package="cn.smbms.controller"/> 
20 
21     <!-- 完成视图的对应 -->
22     <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
23     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
24         <property name="prefix" value="/WEB-INF/jsp/"/>
25         <property name="suffix" value=".jsp"/>
26     </bean>
27 
28 </beans>

Spring MVC体系结构

技术分享图片

技术分享图片

技术分享图片

Spring MVC框架特点

技术分享图片

 View to Controller

技术分享图片

技术分享图片

 Controller to View

技术分享图片

 

Spring MVC体系

原文:https://www.cnblogs.com/1097123611-abc/p/10435173.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!