美文网首页
spring boot模板引擎

spring boot模板引擎

作者: 逗比punk | 来源:发表于2017-07-14 23:02 被阅读44次

web应用开发-模板引擎
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 默认的错误页面
FreeMarker Demo
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
Thymeleaf Demo
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

相关文章

网友评论

      本文标题:spring boot模板引擎

      本文链接:https://www.haomeiwen.com/subject/wxauhxtx.html