欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

springboot + JSP

程序员文章站 2022-05-26 10:13:44
...

 添加JPS引擎依赖

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

创建webapp文件夹里面放jsp文件

springboot + JSP

 yml配置

server:
  port: 9090
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.1.6:3306/quartz?characterEncoding=utf8&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&useSSL=false
    username: sa
    password: 123456
#  resources:
#    static-locations: classpath:/templates #访问静态页面
#  thymeleaf:
#    mode: LEGACYHTML5 #取消thymeleaf严格的html5校验
#    prefix: classpath:/templates
#    suffix: .html
  mvc:
    view:
      prefix: /  #jsp模板引擎配置
      suffix: .jsp

将关于thymeleaf的全部删除

Controller

/**
     * 测试整合jsp
     * @return Result
     */
    @GetMapping(value = "/testJsp")
    public String testJsp(){
        return "test";
    }

效果

springboot + JSP

相关标签: jsp springboot