存档9月 2021

thymeleaf

thymeleaf

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<p th:text="#{home.welcome}">welcome</p>
<p data-th-text="#{home.welcome}">welcome</p>

娈量表达式 ${}
消息表达式 #{}
选择表达式 *{} 在当前变量表达式中取值
链接表达式 @{} @{../} @{~/} @{//} @{http://}
分段表达式 th:insert th:replace  th:include(不推荐使用)
文本 th:text
比较 >gt <lt >=ge <=le ==eq !=ne
无操作 _ ?:_
设置属性值 th:attr="action=@{/subscribe}"
迭代器 th:each <li th:each="book : ${books}" th:text="${book.title}">en</li>
    状态变量 index(从0开始),count,size,current,even/odd(奇偶数),first,last
条件 th:if th:unless th:switch th:case
片段定义 <div th:fragment="copy">  <div th:insert="~{footer::copy}"></div>
        <div id="copy">  <div th:insert="~{footer::#copy}"></div>
解析器级注释 <!--/* */-->
原型注释块 <!--/*/ /*/-->
内联表达式 [[]] th:text [()]th:utext 禁用内联 th:inline="none"
基本对象 #ctx #local #request #session #selrvletContext param/session/application

implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0'

log日志

日志门面
JCL
*SLF4J
jboos-logging

日志实现
Log4j
Log4j2
*Logback
JUL

日志文件配制

    <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-context</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>

application.yml

logging:
  pattern:
    console: "%d - %msg%n"
  file:
    path: /log/weixin

logback-spring.xml

<?xml version="1.0" encoding="UTF-8" ?>
<configuration >
    <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
        <!--控制台日志显示-->
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>
                %d - %msg%n
            </pattern>
        </layout>
    </appender>
    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!--文件非ERROR日志-->
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <!--禁止ERROR日志-->
            <level>ERROR</level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <encoder>
            <pattern>
                %d - %msg%n
            </pattern>
        </encoder>
        <!--滚动策略 按时间每天一个日志文件-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--文件路径-->
            <fileNamePattern>
                /log/weixin/info.%d.log
            </fileNamePattern>
        </rollingPolicy>
    </appender>

    <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!--文件ERROR日志-->
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <!--仅ERROR日志-->
            <level>ERROR</level>
        </filter>
        <encoder>
            <pattern>
                %d - %msg%n
            </pattern>
        </encoder>
        <!--滚动策略 按时间每天一个日志文件-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--文件路径-->
            <fileNamePattern>
                /log/weixin/error.%d.log
            </fileNamePattern>
        </rollingPolicy>
    </appender>

    <root level="info">
        <appender-ref ref="consoleLog"/>
        <appender-ref ref="fileInfoLog"/>
        <appender-ref ref="fileErrorLog"/>
    </root>
</configuration>