Springboot使用JSP

Springboot使用jsp注意事项:
pom.xml依赖:

 

        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
        
        
            javax.servlet
            javax.servlet-api
            provided
        

        
            javax.servlet
            jstl
        

        
        
            org.apache.tomcat.embed
            tomcat-embed-jasper
            
        
        
        
            org.mybatis
            mybatis
            3.5.3
        
        
        
            mysql
            mysql-connector-java
            5.1.47
        
        
        
            org.mybatis.generator
            mybatis-generator-core
            1.4.0
        
        
            org.mybatis.generator
            mybatis-generator-maven-plugin
            1.4.0
        
        
        
            org.apache.logging.log4j
            log4j-core
            2.12.1
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.1.1
        
        
            org.springframework.boot
            spring-boot-starter
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.1.1
        
        
        
            com.alibaba
            fastjson
            1.2.62
        
        
        
            com.github.pagehelper
            pagehelper-spring-boot-starter
            1.2.5
        
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
        
            
                src/main/java
                
                    **/*.xml
                
            
             
            
                src/main/resources
                
                    **/*.*
                
            
            
                src/main/webapp
                META-INF/resources
                
                    **/*.*
                
            
        
    

application.yml文件配置

#项目启动端口
server:
  port: 8080
  tomcat:
    uri-encoding: UTF-8
#关闭模板引擎缓存
spring:
  thymeleaf:
    cache: false
    encoding: UTF-8
  mvc:
    view:
      # 页面默认前缀目录
      prefix: /WEB-INF/views/
      # 响应页面默认后缀
      suffix: .jsp
    static-path-pattern: /static/**
  http:
    encoding:
      force: true
      charset: UTF-8
      enabled: true
  datasource:
    url: jdbc:mysql://localhost:3306/videowebsite?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
    username: 自己的数据库用户名
    password: 自己的数据密码
    driver-class-name: com.mysql.jdbc.Driver
  resources:
    static-locations: classpath:/static,classpath:/view/,classpath:/public,classpath:/resources,classpath:/META-INF/resources
mybatis:
  config-location: classpath:mybatis-config.xml
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: cn.hongpeiming.pojo #实体类包名路径

项目目录建立样例:
Springboot使用JSP_第1张图片
注意:resources目录下放资源文件,webapp目录应当置为web目录,下面应当建立WEB-INF目录
Springboot使用JSP_第2张图片

控制器代码编写:
Springboot使用JSP_第3张图片

你可能感兴趣的:(springboot)