zoukankan      html  css  js  c++  java
  • Spring thymeleaf

    1.maven项目引入thymeleaf包

    在pom.xml文件中,添加依赖

        <!-- 依赖库 -->
        <dependencies>
            <!-- Springboot核心 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            
            <!-- logging -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </dependency>
    
            <!-- mybatis + mysql -->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.3.0</version>
            </dependency>
            <dependency><!-- 分页插件 -->
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>1.2.10</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
            
            <!-- AOP -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-aop</artifactId>
            </dependency>
            
            <!--start thymeleaf -->
            <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-thymeleaf</artifactId>  
            </dependency>
            
            <!--Quartz
            Spring 项目整合 Quartz 主要依靠添加 SchedulerFactoryBean 这个 FactoryBean,
             所以在maven 依赖中添加 spring-context-support 。-->
            <dependency>
              <groupId>org.quartz-scheduler</groupId>
              <artifactId>quartz</artifactId>
            </dependency>
            <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>spring-context-support</artifactId>
            </dependency>
            
            <!-- security-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
            </dependency>
            <dependency>
                <groupId>org.thymeleaf.extras</groupId>
                <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            </dependency>
            
            <!-- 支持 @ConfigurationProperties 注解 -->  
            <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-configuration-processor</artifactId>  
                <optional>true</optional>  
            </dependency>  
    
            <!-- java mail -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-mail</artifactId>
            </dependency>
    
            <!-- 支持 Excel操作 -->  
            <dependency>  
                <groupId>org.apache.poi</groupId>  
                <artifactId>poi-ooxml</artifactId>  
                <version>3.9</version>  
            </dependency>
        </dependencies>

    2..application.yml中添加:

        thymeleaf: #thymeleaf
            prefix: classpath:/templates/
            suffix: .html
            mode: HTML
            encoding: UTF-8
            cache: true #turn off when in developing or cant refresh immdiately
            servlet:
                content-type: text/html

    3.在HTML中添加:

    <html xmlns:th="http://www.thymeleaf.org"
        xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
  • 相关阅读:
    [翻译]关于堆和堆栈
    sql 字符+数值 混合排序 lcs
    证明DataReader分页的可行性 lcs
    谈谈我对小公司、大公司及个人成长的见解 lcs
    sina 通用js代码说明 lcs
    Linux系统下生成证书 https证书
    【转】51单片机外部中断的C51编程
    【转】如何建立个人网站
    【转】关于C51的中断编程[原创]
    【转】毫不费力:破解加密PDF文档就使用这两三招
  • 原文地址:https://www.cnblogs.com/jszfy/p/11175238.html
Copyright © 2011-2022 走看看