SpringMVC
一.. SpringMVC重要组件介绍
1. DispacherServlet:前端控制器,接收所有请求,(如果配置/不包含jsp)
2. HandlerMapping:解析请求格式,判断希望要执行哪个方法
3. HandlerAdapter:负责调用具体的方法
4. ViewResovler:视图解析器,解析结果,准备跳转的具体的视图
spring的jar包官方下载地址:
https://repo.spring.io/libs-release-local/org/springframework/spring/
二. 环境搭建
1.导入jar包
2.在web.xml中配置前端控制器,若不配置
3.src下面新建springmvc.xml
3.1.引入命名空间
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
3.2.编写控制器类
1 @Controller
2 public class Democontroller {
3 @RequestMapping("demo")
4 public String demo(){
5 return "main.jsp";
6 }
7
8 }
参与评论
手机查看
返回顶部