一 Tomcat官网下载最新的tomcat
二 创建Spring web工程
![](https://i-blog.csdnimg.cn/blog_migrate/7b25b8507462f144e60626451ed4fcc1.png)
![](https://i-blog.csdnimg.cn/blog_migrate/b90dff1aa618995220f3e4465f7986b7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/565f66a16111ff7e973a54f4768b1195.png)
三 调整项目视图结构
1 删除错误的目录
![](https://i-blog.csdnimg.cn/blog_migrate/57d10a67e40c82cb175914d593687bc8.png)
2 新增1个文件夹
![](https://i-blog.csdnimg.cn/blog_migrate/80495b8842296d1603493fd171aab7ce.png)
3 调整位置
![](https://i-blog.csdnimg.cn/blog_migrate/d72b381e53a22c3a069bbae4e100cebb.png)
4 调整后的试图结构
![](https://i-blog.csdnimg.cn/blog_migrate/6659346302f5299ac4e36a5ca90357be.png)
四 编辑pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd";>
<modelVersion>4.0.0</modelVersion>
<groupId>cn.itsource</groupId>
<artifactId>springboot-jsp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-jsp Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<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>
</dependencies>
</project>
五 引入Tomcat的环境依赖
1 添加Tomcat Server,选择【Windows】->【Preferences】
![](https://i-blog.csdnimg.cn/blog_migrate/9ba6493160ca8098138141f8b889baef.png)
![](https://i-blog.csdnimg.cn/blog_migrate/83a79e2cd4d1631bd78de34ac5c72e69.png)
2 添加Tomcat依赖,选择项目,右键选择属性
![](https://i-blog.csdnimg.cn/blog_migrate/8e7d98c7a8451d574575db9e030f7b53.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d5b231357a39a4a4f78ef54090c80b77.png)
![](https://i-blog.csdnimg.cn/blog_migrate/827d6ee28cd8f5fbfdef8d5749c2fb2d.png)
六 编辑application-properties
server.port=80
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
七 在WEB-INF下建立文件夹jsp
八 新建立一个JSP页面hello.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Springboot test</h1>
<p>
${himsg}
</p>
</body>
</html>
九 创建Controller
package cn.itsource.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello(Model model){
model.addAttribute("himsg","welcome to come here");
return "hello";
}
}
十 创建启动程序App
package cn.itsource.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args){
SpringApplication.run(App.class, args);
}
}
十一 启动程序,测试结果
![](https://i-blog.csdnimg.cn/blog_migrate/00015ca83a1c6563bcd96a6a1aad6e65.png)
十二 参考