- spring boot的web應用開發,是基於spring mvc
- Spring boot 在spring默認基礎上,自動配置添加了以下特性:
- 包含了ContentNegotiatingViewResolver和BeanNameViewResolver beans。
- 對靜態資源的支持,包括對WebJars的支持。
- 自動註冊Converter,GenericConverter,Formatter beans。
- 對HttpMessageConverters的支持。
- 自動註冊MessageCodeResolver。
- 對靜態index.html的支持。
- 對自定義Favicon的支持。
- 主動使用ConfigurableWebBindingInitializer bean
- 模板引擎的選擇
FreeMarker
Thymeleaf
Velocity (1.4版本之後棄用,Spring Framework 4.3版本之後棄用)
Groovy
Mustache
注:jsp應該儘量避免使用,原因如下:
- jsp只能打包爲:war格式,不支持jar格式,只能在標準的容器裏面跑(tomcat,jetty都可以)
- 內嵌的Jetty目前不支持JSPs
- Undertow不支持jsps
- jsp自定義錯誤頁面不能覆蓋spring boot 默認的錯誤頁面
- Thymeleaf Demo
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>