1.创建spring starter project
创建时选择maven项目。
2.引入jar包依赖,在pom.xml文件中新增如下内容
<!-- tomcat支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- jsp标签库 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
3.在application.properties中配置jsp设置
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
4.在src/main文件夹下新建如下目录
![](https://i-blog.csdnimg.cn/blog_migrate/67b9047c7823f4f4537574efa720be77.png)
5.编写Controller类测试页面跳转
import org.springframework.web.bind.annotation.RequestMapping;
@org.springframework.stereotype.Controller
public class Controller {
@RequestMapping("/")
public String welcome(){
return "index";
}
}
6.运行SpringApplication.run(FirstApplication.class, args);在浏览器输入http://localhost:8080/