1 Star 0 Fork 0

front-devops / Springboot-Layui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
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/

  2. JPA 通过@Query和JPQL分页查询

    //JPQL
    @Query(value = "SELECT u FROM User u ORDER BY id")
    Page<User> findAllUsersWithPagination(Pageable pageable);
    
    // Native
    @Query(
            value = "SELECT * FROM Users ORDER BY id",
            countQuery = "SELECT count(*) FROM Users",
            nativeQuery = true)
    Page<User> findAllUsersWithPagination(Pageable pageable);
  3. Mysql 5.7 创建create_time和update_time字段自动更新

     `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  4. JPA 存在updateTime字段时,更新Entity对象,如果updateTime为Null,会导致数据库不自动更新update_time字段,并设置成NULL

     @EnableJpaAuditing
     @SpringBootApplication
     public class Springboot2DemoApplication {}
    
     // @LastModifiedDate 自动设置updateTime
     @Column(name = "update_time")
     @Temporal(TemporalType.TIMESTAMP)
     @JsonFormat
     @LastModifiedDate
     private Date updateTime;
  5. Ignoring null Parameters Using the @Query Annotation

    @Query("SELECT c FROM Customer c WHERE (:name is null or c.name = :name) and (:email is null"
      + " or c.email = :email)")
    List<Customer> findCustomerByNameAndEmail(@Param("name") String name, @Param("email") String email);
  6. HTML通过flex实现左右DIV布局

    <div style="display: flex;
              flex-flow: row nowrap;
              justify-content: space-between;">
        <div>left</div>
        <div>right</div>
    </div>
  7. thymeleaf th:href添加URL参数

    <a th:href="@{/index(param1='value1',param2='value2')}">
  8. thymeleaf 获取当前Request中的参数、Session参数 somesite.com/login?error=true

      <div id="errors" th:if="${(param.error != null) and (param.error[0] == 'true')}">
        Input is incorrect
        </div>

    session params

     ${session.foo} // Retrieves the session atttribute 'foo'
     ${session.size()}
     ${session.isEmpty()}
     ${session.containsKey('foo')}
  9. thymeleaf Null 安全

    <td th:text="${user?.address?.city}"></td>
    <span th:text="${object.property} ? 'this is good' : 'default value'"></span>
    <span th:text="${object.property} ?: 'default value'"></span>
  10. thymeleaf 字符串isEmpty判断

    ${#strings.isEmpty(name)}
    
    // is true if name is not empty
    ${!#strings.isEmpty(name)} or ${not #strings.isEmpty(name)} 

空文件

简介

sanbuliuxin/springboot-layui 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/front-devops/springboot-layui.git
git@gitee.com:front-devops/springboot-layui.git
front-devops
springboot-layui
Springboot-Layui
master

搜索帮助