springboot 整合 jsp 页面
创建 springboot 项目就不废话了。在原来的基础上直接加东西就可以了
1、添加 jsp 支持的 jar 包
<!-- servlet 依赖 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- 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>
</dependency>
2、修改 application.properties 配置文件,添加两句
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
3、webapp–>WEB-INF–>jsp 添加一个 index.jsp 页面,随便加一句话
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>hello springboot 2.0.3</h1>
</body>
</html>
4、启动项目,打开 localhost:8080/index.jsp,看到输入的文字,就解决了
标签:SpringBoot,spring,jsp,servlet,javax,模板,springboot From: https://www.cnblogs.com/mountainstudy/p/17603640.html