Springboot2模塊系列:thymeleaf+Bootstrap(一)前後端結合--項目結構

1 pom.xml

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2 文件

2.1 Bootstrap文件

下載Bootstrap,放置到靜態文件夾static下,文件包括css和js文件,結構如下:

├── static
│   ├── css
│   │   ├── bootstrap.css
│   │   ├── bootstrap.css.map
│   │   ├── bootstrap-grid.css
│   │   ├── bootstrap-grid.css.map
│   │   ├── bootstrap-grid.min.css
│   │   ├── bootstrap-grid.min.css.map
│   │   ├── bootstrap.min.css
│   │   ├── bootstrap.min.css.map
│   │   ├── bootstrap-reboot.css
│   │   ├── bootstrap-reboot.css.map
│   │   ├── bootstrap-reboot.min.css
│   │   ├── bootstrap-reboot.min.css.map
│   │   └── peopleInfos.css
│   ├── js
│   │   ├── bootstrap.bundle.js
│   │   ├── bootstrap.bundle.js.map
│   │   ├── bootstrap.bundle.min.js
│   │   ├── bootstrap.bundle.min.js.map
│   │   ├── bootstrap.js
│   │   ├── bootstrap.js.map
│   │   ├── bootstrap.min.js
│   │   ├── bootstrap.min.js.map
│   │   ├── jquery-3.2.1.js
│   │   ├── jquery-3.2.1.min.js
│   │   ├── jquery-3.4.1.js
│   │   ├── jquery-3.4.1.min.js
│   │   ├── jquery.js
│   │   ├── jquery插件庫.url
│   │   ├── sockjs.min.js
│   │   └── stomp.min.js

2.2 界面模板文件

2.2.1 static文件

├── static
│   ├── app.js
│   ├── assets
│   │   ├── brand
│   │   │   ├── bootstrap-outline.svg
│   │   │   └── bootstrap-solid.svg
│   │   └── dist
│   │       ├── css
│   │       └── js
│   ├── chat.html
│   ├── chat.js
│   ├── css
│   │   ├── album
│   │   │   ├── album.css
│   │   │   └── index.html
│   │   ├── blog
│   │   │   ├── blog.css
│   │   │   └── index.html
│   │   ├── bootstrap.css
│   │   ├── bootstrap.css.map
│   │   ├── bootstrap-grid.css
│   │   ├── bootstrap-grid.css.map
│   │   ├── bootstrap-grid.min.css
│   │   ├── bootstrap-grid.min.css.map
│   │   ├── bootstrap.min.css
│   │   ├── bootstrap.min.css.map
│   │   ├── bootstrap-reboot.css
│   │   ├── bootstrap-reboot.css.map
│   │   ├── bootstrap-reboot.min.css
│   │   ├── bootstrap-reboot.min.css.map
│   │   ├── dashboard
│   │   │   ├── dashboard.css
│   │   │   ├── dashboard.js
│   │   │   └── index.html
│   │   ├── datasshow
│   │   │   └── datasshow.css
│   │   ├── sign-in
│   │   │   └── signin.css
│   │   └── user-info
│   │       └── userinfo.css
│   ├── js
│   │   ├── bootstrap.bundle.js
│   │   ├── bootstrap.bundle.js.map
│   │   ├── bootstrap.bundle.min.js
│   │   ├── bootstrap.bundle.min.js.map
│   │   ├── bootstrap.js
│   │   ├── bootstrap.js.map
│   │   ├── bootstrap.min.js
│   │   ├── bootstrap.min.js.map
│   │   ├── datasshow
│   │   │   └── dashboard.js
│   │   ├── jquery-3.2.1.js
│   │   ├── jquery-3.2.1.min.js
│   │   ├── jquery-3.4.1.js
│   │   ├── jquery-3.4.1.min.js
│   │   ├── jquery.js
│   │   ├── jquery插件庫.url
│   │   ├── sockjs.min.js
│   │   ├── stomp.min.js
│   │   └── user-info
│   │       └── userinfo.js
│   ├── sign-in
│   │   ├── index.html
│   │   └── signin.css

2.2.2 templates文件

使用Thymeleaf模塊,將前端頁面放置在templates文件夾下,文件結構如下:

└── templates
    ├── datasshow
    │   └── index.html
    ├── sign-in
    │   ├── index.html

3 項目結構

├── micros-user
│   ├── logs
│   │   ├── error.log
│   │   └── info.log
│   ├── pom.xml
│   ├── sqltools_20200512090140_17607.log
│   ├── src
│   │   └── main
│   │       ├── java
│   │       │   └── com
│   │       │       └── company
│   │       │           └── web
│   │       │               ├── config
│   │       │               │   ├── AuthorizationServerConfig.java
│   │       │               │   ├── ResourceServerConfig.java
│   │       │               │   ├── StaticResourcesLoadConfig.java
│   │       │               │   └── WebSecurityConfig.java
│   │       │               ├── controller
│   │       │               │   ├── AjaxController.java
│   │       │               │   ├── AnswersController.java
│   │       │               │   ├── ExchangeDataController.java
│   │       │               │   ├── ExchangeData.java
│   │       │               │   ├── PageController.java
│   │       │               │   ├── PageInterceptController.java
│   │       │               │   ├── QuestionsController.java
│   │       │               │   └── TokenByRedisController.java
│   │       │               ├── InitiApplication.java
│   │       │               ├── mapper
│   │       │               │   ├── AnswersMapper.java
│   │       │               │   ├── AnswersMapper.xml
│   │       │               │   ├── QuestionsMapper.java
│   │       │               │   ├── QuestionsMapper.xml
│   │       │               │   ├── UserInfosMapper.java
│   │       │               │   └── UserInfosMapper.xml
│   │       │               ├── po
│   │       │               │   ├── Answers.java
│   │       │               │   ├── Questions.java
│   │       │               │   └── UserInfos.java
│   │       │               ├── service
│   │       │               │   ├── AnswersService.java
│   │       │               │   ├── QuestionsService.java
│   │       │               │   └── UserInfosService.java
│   │       │               └── util
│   │       │                   ├── http
│   │       │                   └── https
│   │       ├── resources
│   │       │   ├── application-dev.yml
│   │       │   ├── application.yml
│   │       │   ├── config
│   │       │   │   ├── logback.xml
│   │       │   │   └── mybatis-config.xml
│   │       │   ├── jar
│   │       │   ├── sql
│   │       │   │   └── data.sql
│   │       │   ├── ssl-pre
│   │       │   ├── ssl-rc
│   │       │   ├── ssl-test
│   │       │   ├── static
│   │       │   │   ├── app.js
│   │       │   │   ├── assets
│   │       │   │   │   ├── brand
│   │       │   │   │   │   ├── bootstrap-outline.svg
│   │       │   │   │   │   └── bootstrap-solid.svg
│   │       │   │   │   └── dist
│   │       │   │   │       ├── css
│   │       │   │   │       │   ├── bootstrap.css
│   │       │   │   │       │   ├── bootstrap.css.map
│   │       │   │   │       │   ├── bootstrap-grid.css
│   │       │   │   │       │   ├── bootstrap-grid.css.map
│   │       │   │   │       │   ├── bootstrap-grid.min.css
│   │       │   │   │       │   ├── bootstrap-grid.min.css.map
│   │       │   │   │       │   ├── bootstrap.min.css
│   │       │   │   │       │   ├── bootstrap.min.css.map
│   │       │   │   │       │   ├── bootstrap-reboot.css
│   │       │   │   │       │   ├── bootstrap-reboot.css.map
│   │       │   │   │       │   ├── bootstrap-reboot.min.css
│   │       │   │   │       │   └── bootstrap-reboot.min.css.map
│   │       │   │   │       └── js
│   │       │   │   │           ├── bootstrap.bundle.js
│   │       │   │   │           ├── bootstrap.bundle.js.map
│   │       │   │   │           ├── bootstrap.bundle.min.js
│   │       │   │   │           ├── bootstrap.bundle.min.js.map
│   │       │   │   │           ├── bootstrap.js
│   │       │   │   │           ├── bootstrap.js.map
│   │       │   │   │           ├── bootstrap.min.js
│   │       │   │   │           └── bootstrap.min.js.map
│   │       │   │   ├── css
│   │       │   │   │   ├── bootstrap.css
│   │       │   │   │   ├── bootstrap.css.map
│   │       │   │   │   ├── bootstrap-grid.css
│   │       │   │   │   ├── bootstrap-grid.css.map
│   │       │   │   │   ├── bootstrap-grid.min.css
│   │       │   │   │   ├── bootstrap-grid.min.css.map
│   │       │   │   │   ├── bootstrap.min.css
│   │       │   │   │   ├── bootstrap.min.css.map
│   │       │   │   │   ├── bootstrap-reboot.css
│   │       │   │   │   ├── bootstrap-reboot.css.map
│   │       │   │   │   ├── bootstrap-reboot.min.css
│   │       │   │   │   ├── bootstrap-reboot.min.css.map
│   │       │   │   │   ├── dashboard
│   │       │   │   │   │   ├── dashboard.css
│   │       │   │   │   │   ├── dashboard.js
│   │       │   │   │   │   └── index.html
│   │       │   │   │   ├── datasshow
│   │       │   │   │   │   └── datasshow.css
│   │       │   │   │   ├── sign-in
│   │       │   │   │   │   └── signin.css
│   │       │   │   │   └── user-info
│   │       │   │   │       └── userinfo.css
│   │       │   │   ├── js
│   │       │   │   │   ├── bootstrap.bundle.js
│   │       │   │   │   ├── bootstrap.bundle.js.map
│   │       │   │   │   ├── bootstrap.bundle.min.js
│   │       │   │   │   ├── bootstrap.bundle.min.js.map
│   │       │   │   │   ├── bootstrap.js
│   │       │   │   │   ├── bootstrap.js.map
│   │       │   │   │   ├── bootstrap.min.js
│   │       │   │   │   ├── bootstrap.min.js.map
│   │       │   │   │   ├── datasshow
│   │       │   │   │   │   └── dashboard.js
│   │       │   │   │   ├── jquery-3.2.1.js
│   │       │   │   │   ├── jquery-3.2.1.min.js
│   │       │   │   │   ├── jquery-3.4.1.js
│   │       │   │   │   ├── jquery-3.4.1.min.js
│   │       │   │   │   ├── jquery.js
│   │       │   │   │   ├── jquery插件庫.url
│   │       │   │   │   ├── sockjs.min.js
│   │       │   │   │   ├── stomp.min.js
│   │       │   │   │   └── user-info
│   │       │   │   │       └── userinfo.js
│   │       │   │   ├── sign-in
│   │       │   │   │   ├── index.html
│   │       │   │   │   └── signin.css
│   │       │   └── templates
│   │       │       ├── datasshow
│   │       │       │   └── index.html
│   │       │       ├── sign-in
│   │       │       │   └── index.html
│   │       └── webapp
│   │           ├── index.jsp
│   │           └── WEB-INF
│   │               └── web.xml

【參考文獻】
[1]https://getbootstrap.com/docs/4.5/getting-started/download/
[2]https://www.runoob.com/bootstrap/bootstrap-environment-setup.html
[3]https://www.cnblogs.com/lanxuan826/p/11221603.html
[4]https://www.cnblogs.com/hfultrastrong/p/8583874.html
[5]https://blog.csdn.net/qq_40058321/article/details/98478488
[6]https://blog.csdn.net/yelllowcong/article/details/79830468
[7]https://blog.csdn.net/u010999809/article/details/80726248
[8]https://www.pianshen.com/article/1066405203/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章