SpringBoot+JSP

1.

1fc201e03c4f7eb0bd55807fcd52078f20f.jpg

2.

a1cb369d5fb003ff0cc0d0af49268cd7457.jpg

3.

b7a7b13eddee26ab36c23023e79bd13da26.jpg

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.目录结构

8470f6f8a8d0703cf3dde0724f96160072b.jpg

7.File-Project Structure将webapp设为web文件夹

f4ca99f160864fbc77e52dfcbbc4e020207.jpg

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.运行效果

3b90599d1163bdd466a46897b361004a958.jpg

转载于:https://my.oschina.net/u/3876440/blog/3030061

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值