框架二:Spring MVC

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

处理的是DataAccessOBject数据访问对象

SpringMVC它隶属于Spring框架,它只是Spring这个庞大框架下的一个小模块,SpringMVC是替换我们之前学过的Servlet,在我们下面的课程的时候需要你回顾Servlet

如何学习一个框架?

1.jar

2.配置核心配置文件

3.读取核心配置文件

4.测试Hello World

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

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方法->判断用dogetdopost

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

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


130444_ZLlx_2319558.jpg

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.

建立的XML 文件必须是配置的web.xml中的servlet-name 的名字+"-"+servlet.xml


130648_bTPx_2319558.jpg

自动默认的地址发送方式为请求转发


130738_hfAR_2319558.jpg

配置JSP试图解析器: 只能在请求转发中使用,不能用于重定向。解析器运用:mav.setViewName("shxt")省略掉/WEB-INF/文件夹,因为已经配置完成了,省略后缀.jsp;

130832_yRPy_2319558.jpg

 

Caused by: java.lang.IllegalStateException: Ambiguous (模棱两可的错误)mapping. Cannot map 'homeController' method 

当下列的value的值为同一个时,则会出现上述的错误,此时就需要将转发的方式标注出来,是post,get,还是其他的方式。这样就避免了错误。

method=RequestMethod.转发方式


130943_QQuX_2319558.jpg

 




转载于:https://my.oschina.net/courage123/blog/652269

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值