一、概述
Spring为展现层提供的基于MVC设计理念的优秀的Web框架,是目前最流行的MVC框架之一
Spring3.0后全面超越Struts2,称为最优秀的MVC框架
SpringMVC通过一套MVC注解,让POJO成为处理请求的控制器,而无须实现任何接口。
支持REST风格的URL请求
采用了松散耦合可插拔组件结构,比其他MVC框架更具扩展性和灵活性。
二、HelloWorld
步骤:
加入jar 包
在web.xml 中配置DispatcherServlet
加入Spring MVC 的配置文件
编写处理请求的处理器,并标识为处理器
编写视图
(1)加入jia包

(2)在web.xml中配置DispatcherServlet

(3)加入springmvc的配置文件

(4)编写处理请求的处理器,并标识为处理器

(5)编写视图


使用 @RequestMapping 注解来映射请求的 URL
返回值会通过视图解析器解析为实际的物理视图, 对于 InternalResourceViewResolver 视图解析器, 会做如下的解析:通过 prefix + returnVal + suffix 这样的方式得到实际的物理视图, 然会做转发操作/WEB-INF/views/success.jsp
网友评论