1.
2.
3.
4.下一步Finish
5.pom更改
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- web项目依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<!--注意:spring boot对jsp的支持不是很好,在使用spring boot自带tomcat的同时,还需要引入另外的一个tomcat,且scope属性需要被注释掉 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope> -->
</dependency>
<!-- jsp标签库 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
6.目录结构
7.File-Project Structure将webapp设为web文件夹
8.application.yml
spring:
mvc:
view:
prefix: /WEB-INF/page/
suffix: .jsp
9.PageController.java
@Controller
public class PageController {
@RequestMapping(value = "/hello")
public String hello(){
return "hello";
}
}
10.hello.jsp
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2019/3/30 0030
Time: 11:10
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
你好
</body>
</html>
10.运行效果