当前位置: 首页 > news >正文

三级分类bug解决

文章目录

  • 前端
  • 后端

前端

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>分类展示页面</title><!-- 你可以在这里添加CSS样式链接,例如: --><!-- <link rel="stylesheet" href="/css/styles.css"> -->
</head>
<body><!-- 页面主体内容开始 --><div class="container"><!-- 分类列表开始 --><div class="category-list" th:if="${not #lists.isEmpty(categorys)}"><div class="item" th:each="category : ${categorys}"><h3><a href="#" th:href="@{/category/view(id=${category.id})}" th:text="${category.name}">分类名称</a></h3><div class="item-list clearfix" th:if="${not #lists.isEmpty(category.category2VoList)}"><div class="subitem" th:each="category2 : ${category.category2VoList}"><dl class="fore" th:if="${not #lists.isEmpty(category2.category3VoList)}"><dt><a href="#" th:href="@{/category/view(id=${category2.id})}" th:text="${category2.name}">子分类名称</a></dt><dd><em th:each="category3 : ${category2.category3VoList}"><a href="#" th:href="@{/category/view(id=${category3.id})}" th:text="${category3.name}">三级分类名称</a></em></dd></dl><!-- 如果没有三级分类,显示占位符 --><div th:unless="${not #lists.isEmpty(category2.category3VoList)}" class="no-subcategories"><p>暂无三级分类</p></div></div><!-- 如果没有二级分类,理论上这里不应该进入这个分支,因为上面的th:if已经检查了 --><!-- 但为了完整性,可以保留这个结构,并确保在数据准备时二级分类列表不为空 --></div><!-- 如果确实需要处理没有二级分类的情况(尽管逻辑上不应该),可以这样写: --><!-- <div th:unless="${not #lists.isEmpty(category.category2VoList)}" class="no-subcategories"> --><!--     <p>暂无二级分类</p> --><!-- </div> --></div></div><!-- 如果没有任何一级分类,显示占位符(这个通常不会在数据准备时发生,除非有特定逻辑) --><div th:unless="${not #lists.isEmpty(categorys)}" class="no-categories"><p>暂无分类信息</p></div><!-- 分类列表结束 --></div><!-- 页面主体内容结束 --><!-- 你可以在这里添加JavaScript脚本链接,例如: --><!-- <script src="/js/scripts.js"></script> -->
</body>
</html>

后端

private List<CategoryEntity> getParentId(List<CategoryEntity> selectList, Integer parentId) {return selectList.stream().filter(item -> item.getParentId().equals(parentId)) // 使用 equals 比较 Integer,避免 NullPointerException.collect(Collectors.toList());// 如果需要返回 null 而不是空列表,可以添加以下判断:// if (result.isEmpty()) return null; else return result;
}
http://www.lryc.cn/news/541841.html

相关文章:

  • AxiosError: Network Error
  • CDefFolderMenu_MergeMenu函数分析之添加了分割线和属性菜单项两项
  • mysql的源码包安装
  • win11系统无法打开软件_组策略无法打开_gpedit.msc不生效_为了对电脑进行保护,已经阻止此应用---Windows工作笔记057
  • 【JAVA】io流之缓冲流
  • from flask_session import Session 为什么是Session(app)这么用?
  • AI赋能的未来城市:如何用智能化提升生活质量?
  • 【Go】Go wire 依赖注入
  • 深度集成DeepSeek与Java开发:智能编码新纪元全攻略 [特殊字符]
  • WEB前端将指定DOM生成图片并下载最佳实践(html2canvas)
  • 掌握.NET Core后端发布流程,如何部署后端应用?
  • 深度学习学习笔记(34周)
  • C++ 设计模式-备忘录模式
  • TOGAF之架构标准规范-信息系统架构 | 应用架构
  • 第一届网谷杯
  • Linux(ubuntu) GPU CUDA 构建Docker镜像
  • mysql -DQL语句和DCL语句
  • 掌握 ElasticSearch 组合查询:Bool Query 详解与实践
  • C++ 类和对象(友元、内部类、匿名对像)
  • PostgreSQL 常用函数
  • 掌握 ElasticSearch 四种match查询的原理与应用
  • 解决:Conda虚拟环境中未设置CUDA_HOME的问题
  • easyexcel和poi同时存在版本问题,使用easyexcel导出excel设置日期格式
  • HarmonyOS 开发套件 介绍——下篇
  • 关于order by的sql注入实验
  • Transformers快速入门-学习笔记
  • luci界面开发中的MVC架构——LuCI介绍(二)
  • 第1章大型互联网公司的基础架构——1.10 其他NoSQL数据库
  • DeepSeek+Kimi生成高质量PPT
  • web网络安全:跨站脚本攻击(XSS)