三级分类bug解决

server/2025/2/26 1:15:25/

文章目录

  • 前端
  • 后端

前端

<!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.ppmy.cn/server/170653.html

相关文章

如何将本地连接服务器中的文件内容复制到本机的剪贴板

因为任务需要通过了跳板机连接到服务器&#xff0c;修改代码测试代码用原生的VIM很不方便&#xff0c;因此想怎么把服务的代码内容方便的复制到本机&#xff0c;网上相关的介绍内容不太多&#xff0c;不过看到有内容介绍vim插件之类的&#xff0c;碰巧看到一个命令&#xff0c;…

dubbo转http方式调用

业务背景&#xff1a;在当前项目下&#xff0c;所有前端请求均通过外层网关转发到后端这边的dubbo服务&#xff0c;现计划去掉网关层&#xff0c;由前端直接http调用后端dubbo。 解决方案&#xff1a;在前端调用方式不变的前提下&#xff0c;后端服务新建controller层&#xf…

在windows下安装windows+Ubuntu16.04双系统(下)

这篇文章的内容主要来源于这篇文章&#xff0c;为正式安装windowsUbuntu16.04双系统部分。在正式安装前&#xff0c;若还没有进行前期准备工作&#xff08;1.分区2.制作启动u盘&#xff09;&#xff0c;见《在windows下安装windowsUbuntu16.04双系统(上)》 二、正式安装Ubuntu …

数据结构:双链表list

list 是 C 标准库中的双向链表容器。 list初始化示例&#xff1a; #include <list>int n 7;std::list<int> lst; // 初始化一个空的双向链表 lststd::list<int> lst(n); // 初始化一个大小为 n 的链表 lst&#xff0c;链表中的值默认都为 0std::list<i…

Adpative Cursor Sharing引发的Oracle故障案例

&#x1f4e2;&#x1f4e2;&#x1f4e2;&#x1f4e3;&#x1f4e3;&#x1f4e3; 作者&#xff1a;IT邦德 中国DBA联盟(ACDU)成员&#xff0c;10余年DBA工作经验 Oracle、PostgreSQL ACE CSDN博客专家及B站知名UP主&#xff0c;全网粉丝10万 擅长主流Oracle、MySQL、PG、高斯…

【Python】打造自己的HTTP server

词汇汇总 CRLF 指的是换行和回车\r\n 教程 ./your_program.sh #启动自己的服务curl -v http://localhost:4221#开启另一个终端 测试HTTP response An HTTP response is made up of three parts, each separated by a CRLF (\r\n): Status line. Zero or more headers, each …

大语言模型(LLM)微调技术笔记

图1&#xff1a;大模型进化树2 大模型微调 在预训练后&#xff0c;大模型可以获得解决各种任务的通用能力。然而&#xff0c;越来越多的研究表明&#xff0c;大语言模型的能力可以根据特定目标进一步调整。 这就是微调技术&#xff0c;目前主要有两种微调大模型的方法1&…

DeepSeek 全面分析报告

引言 DeepSeek 是一款由中国人工智能初创公司 DeepSeek 开发的大型语言模型 (LLM)&#xff0c;于 2025 年 1 月发布&#xff0c;迅速成为全球人工智能领域的一匹黑马。DeepSeek 不仅在性能上可与 OpenAI、Google 等巨头的模型相媲美&#xff0c;而且其训练成本和运行效率都显著…