回顾Servlet

1.新建一个Maven工程当作父工程,导入pom依赖!

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

 

2.建立一个Model:springmvc-01-servlet,添加Web app支持(在里边添加框架支持)!

 

3.子项目导入servlet和jsp的jar依赖

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>

 

4.编写一个Servlet类,用来处理用户请求

 

5.编写test.jsp,在WEB-INF目录下新建一个jsp文件夹,新建test.jsp

 

6.在web.xml中注册Servlet

 

 7.配置Tomcat,并启动测试

localhost://8080/hello?method=add

localhost://8080/hello?method=delete

 

 

MVC框架要做哪些事情?

1.将url映射到java类或java类的方法

2.封装用户提交的数据

3.处理请求,调用相关业务处理,封装响应数据

4.将响应的数据进行渲染

posted on 2022-05-04 21:59  键盘敲烂的朱  阅读(21)  评论(0编辑  收藏  举报