SpringBoot 載入 .jsp 和 .html頁面
阿新 • • 發佈:2018-12-14
.jsp 在前後端不分離的情況下 這個頁面應該是最常用的了,先看配置
application.yml
server: context-path: /bps spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver username: root password: ROOT url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8 #最大活躍數 maxActive: 20 #初始化數量 initialSize: 1 #最大連線等待超時時間 maxWait: 60000 #開啟PSCache,並且指定每個連線PSCache的大小 poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 #通過connectionProperties屬性來開啟mergeSql功能;慢SQL記錄 #connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 minIdle: 1 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select 1 from dual testWhileIdle: true testOnBorrow: false testOnReturn: false #配置監控統計攔截的filters,去掉後監控介面sql將無法統計,'wall'用於防火牆 filters: stat, wall, log4j jpa: properties: hibernate: show_sql: true format_sql: true dialect: org.hibernate.dialect.MySQL5Dialect naming: #jpa查sql將欄位自動加下劃線(org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl) physical-strategy: org.hibernate.cfg.ImprovedNamingStrategy # ddl-auto: update create (自動建立表,要先建立類,每次都是先刪再建立) update:如果表存在則不建立,只在第一次初始化時建立表 mvc: view: prefix: /WEB-INF/jsp/ suffix: .jsp logging: level: #日誌輸出,可控制路徑,或者級別 --> eureka.manager.controller: 'info' eureka.manager.controller: 'off' # devtools: # restart: # enabled: true #熱部署生效 #設定重啟的目錄 # additional-paths: src/main/java # exclude: WEB-INF/** #classpath目錄下的WEB-INF資料夾內容修改不重啟 #mybatis: # mapper-locations: classpath*:mybatis/*Mapper.xml # type-aliases-package: com.demo.entity #spring: # profiles: # active: dev
其實上面一大堆有用的只有,注意 頂層應該還有 spring:
mvc:
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
Controller
@RequestMapping("/retu") public String jsp(Model model){ List <Items>itemsList =new LinkedList<Items>(); for (int i=0;i<=5;i++) { Items item =new Items(); item.setId(3); item.setDetail("111111"); item.setName("111111"); itemsList.add(item); } model.addAttribute("itemsList", itemsList); return "fir"; }