# Springboot-Layui **Repository Path**: front-devops/springboot-layui ## Basic Information - **Project Name**: Springboot-Layui - **Description**: sanbuliuxin/springboot-layui - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-18 - **Last Updated**: 2024-03-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SpringBoot Layui 基于SpringBoot2.x + layui2.5.x + Thymeleaf + Mysql5.7 版本开发的后台管理系统 ## 问题记录 1. springDataJpa动态代理扩展 给所有的DAO接口添加相同的默认方法: https://blog.csdn.net/weixin_45138931/article/details/102979230 https://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-adding-custom-methods-into-all-repositories/ 1. JPA 通过@Query和JPQL分页查询 ```java //JPQL @Query(value = "SELECT u FROM User u ORDER BY id") Page findAllUsersWithPagination(Pageable pageable); // Native @Query( value = "SELECT * FROM Users ORDER BY id", countQuery = "SELECT count(*) FROM Users", nativeQuery = true) Page findAllUsersWithPagination(Pageable pageable); ``` 1. Mysql 5.7 创建create_time和update_time字段自动更新 ```mysql `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间', ``` 1. JPA 存在updateTime字段时,更新Entity对象,如果updateTime为Null,会导致数据库不自动更新update_time字段,并设置成NULL ```java @EnableJpaAuditing @SpringBootApplication public class Springboot2DemoApplication {} // @LastModifiedDate 自动设置updateTime @Column(name = "update_time") @Temporal(TemporalType.TIMESTAMP) @JsonFormat @LastModifiedDate private Date updateTime; ``` 1. Ignoring null Parameters Using the @Query Annotation ```java @Query("SELECT c FROM Customer c WHERE (:name is null or c.name = :name) and (:email is null" + " or c.email = :email)") List findCustomerByNameAndEmail(@Param("name") String name, @Param("email") String email); ``` 1. HTML通过flex实现左右DIV布局 ```html
left
right
``` 1. thymeleaf th:href添加URL参数 ```html ``` 1. thymeleaf 获取当前Request中的参数、Session参数 somesite.com/login?error=true ```html
Input is incorrect
``` session params ```thymeleaf ${session.foo} // Retrieves the session atttribute 'foo' ${session.size()} ${session.isEmpty()} ${session.containsKey('foo')} ``` 1. thymeleaf Null 安全 ```html ``` 1. thymeleaf 字符串isEmpty判断 ```html ${#strings.isEmpty(name)} // is true if name is not empty ${!#strings.isEmpty(name)} or ${not #strings.isEmpty(name)} ```