# SpringBoot-html
**Repository Path**: yegw/SpringBoot-html
## Basic Information
- **Project Name**: SpringBoot-html
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2019-08-08
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 基于Spring Boot的登录页面
本项目基于Spring Boot框架,搭建了一个简单的登录微服务。
Spring Boot相对于传统的SSM(Spring MVC + Mybatis + Spring)框架用起来更加简单,不需要进行复杂的配置,方便灵活。
Spring Boot让我们的Spring应用变的更轻量化。比如:你可以仅仅依靠一个Java类来运行一个Spring应用。你也可以打包你的应用为jar并通过使用java -jar来运行你的Spring Web应用。
使用Spring Boot可以很方便的建立微服务。
### 效果图
[项目测试地址](http://tianle.me:8080):http://tianle.me:8080

### 应用技术
Spring Boot + bootstrap + thymeleaf
### 项目搭建
使用Intellij中的Spring Initializr来快速构建Spring Boot
菜单栏中选择File=>New=>Project..
一直点下一步




最后点击Finish
联网自动从网站上下载Spring Boot的模板,稍作等待框架就搭好啦。
#### 项目目录结构
上面步骤中的项目名字和这个截图有点不一样(login)
src/main/java/ 为代码文件
src/main/resources/ 为资源文件
为了保证项目资源结构的清晰,我们把 src/main/java/ 再进一步进行划分:
bean 目录存放的是要用到的实体类
controller 目录存放的是控制层类
src/main/resources/template/ 为静态页面的模板文件,这里用了thymeleaf模板渲染引擎框架(据说Spring Boot推荐)
src/main/resources/application.properties 为Spring Boot的配置文件
#### maven配置
我们做的是Java web项目,在其默认生成的maven配置文件中添加web和thymeleaf依赖。
pom.xml
```xml
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-thymeleaf
```
#### application.properties配置
这里我们配置 thymeleaf模板渲染引擎
```
# Enable template caching.
spring.thymeleaf.cache=true
# Check that the templates location exists.
spring.thymeleaf.check-template-location=true
# Content-Type value.
spring.thymeleaf.servlet.content-type=text/html
# Enable MVC Thymeleaf view resolution.
spring.thymeleaf.enabled=true
# Template encoding.
spring.thymeleaf.encoding=UTF-8
# Comma-separated list of view names that should be excluded from resolution.
spring.thymeleaf.excluded-view-names=
# Template mode to be applied to templates. See also StandardTemplateModeHandlers.
spring.thymeleaf.mode=HTML
# Prefix that gets prepended to view names when building a URL.
spring.thymeleaf.prefix=classpath:/templates/
# Suffix that gets appended to view names when building a URL.
spring.thymeleaf.suffix=.html
```
其余的Spring Boot属性配置文件参考(本项目没有配置,使用的默认):
[Spring Boot属性配置文件详解](http://blog.didispace.com/springbootproperties/)