springboot

一:使用Thymeleaf:参考http://blog.csdn.net/u012702547/article/details/53784992#t0

  1.1 引入相应的包

  1.2  thymeleaf配置

    1)配置类方式

@ConfigurationProperties("spring.thymeleaf")
public class ThymeleafProperties {
    private static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8");
    private static final MimeType DEFAULT_CONTENT_TYPE = MimeType.valueOf("text/html");
    public static final String DEFAULT_PREFIX = "classpath:/templates/";
    public static final String DEFAULT_SUFFIX = ".html";
    private boolean checkTemplate = true;
    private boolean checkTemplateLocation = true;
    private String prefix = "classpath:/templates/";
    private String suffix = ".html";
    private String mode = "HTML5";

    ......
    ......
    ......
}
View Code

    2)配置文件

    application.properties文件中以spring.thymeleaf为前缀来配置相关属性

  1.3 tomcat配置

server.port=8081#配置服务器端口,默认为8080
server.session-timeout=1000000#用户回话session过期时间,以秒为单位
server.context-path=/index#配置访问路径,默认为/
server.tomcat.uri-encoding=UTF-8#配置Tomcat编码,默认为UTF-8
server.tomcat.compression=on#Tomcat是否开启压缩,默认为关闭

  1.2 工作原理

    后台通过将javaBean或者其他java对象放入Model对象中,前台页面就可以通过${javaBean.name}来获得值,同时还有很多方法可以使用

   

原文地址:https://www.cnblogs.com/xiaoping1993/p/8025489.html