springboot支持jsp 02

springboot建议使用模板技术如freemarker、thymleaf,不建议使用jsp,但是它支持使用jsp。本文将阐述springboot中如何支持jsp。

1、环境约束

  • win10 64位操作系统
  • idea2018.1.5
  • maven-3.0.5
  • jdk-8u162-windows-x64

2、前提约束

完成springboot创建web项目 https://www.jianshu.com/p/de979f53ad80

3、修改pom.xml

加入依赖如下:

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>

加入resources如下:

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/webapp</directory>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>

4、在src/main当中创建webapp,并加入项目

具体操作如下:

 
16204070-336bc10249451553.gif
创建webapp

5、在src/main/webapp下创建index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    this is jsp page in webapp
</body>
</html>

6、启动项目

 
16204070-05ef9a9805e7f92a.gif
启动项目

7、测试

打开浏览器,输入http://localhost:8888/index.jsp。具体操作如下:

 
16204070-3fff209f0dd22d46.gif
测试


至此,我们完成了在springboot中支持jsp页面,并完成了测试。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值