首页 > 技术文章 > SpringMVC的环境搭建

jiangxiulian 2016-09-28 20:25 原文

MyBatis框架-->持久层框架-->Object【对象】Relation[关系型数据库]Mapping[在MyBatis的体现是哪个映射文件中国的<resultMap>标签]框架  对JDBC的封装,需要定制SQL语句。处理的是DataAccessOBject数据访问对象

SpringMVC它隶属于Spring框架,它只是Spring这个庞大框架下的一个小模块,SpringMVC是替换我们之前学过的Servlet。

 首先如何学习一个框架?

1.找jar

2.配置核心配置文件

3.读取核心配置文件

4.测试Hello World

读取核心配置文件:MyBatis的时候,是由我们自己控制读取mybatis-config.xml Java

SpringMVC框架,WEB层,动态Web项目

第一步:找到Jar[19个]

第二步:建立核心配置文件

 

The DispatcherServlet is an actual Servlet (it inherits from the HttpServlet base class), and as such is declared in the web.xml[部署描述符] of your web application. You need to map requests that you want the DispatcherServlet to handle, by using a URL mapping in the same web.xml file. This is standard Java EE Servlet configuration; the following example shows such a DispatcherServlet declaration and mapping:

 

Servlet的生命周期

发送请求——>如果你是第一次访问获取使用服务器进行初始化操作 init()方法实例化

--》service方法->判断用doget、dopost

<load-on-startup>1</load-on-startup>

<load-on-startup>当服务器启动的时候就对该Servlet实话,并且值越小越被优先加载</load-on-startup>

 

 

 

JSP的生命周期[百度]

 

 

 

Upon initialization of a DispatcherServlet, Spring MVC looks for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and creates the beans defined there, overriding the definitions of any beans defined with the same name in the global scope.

 

 

 

 

 

 

 

 

 

 

 

 

跳转:

请求转发:地址栏路径不变[默认的跳转方式]

 

重定向:地址栏改变

 

 

配置视图解析器

 

 

 

 

 

 

Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'homeController' method

 

 

 

 

 

 

 

 

 

 

推荐阅读