Web前端后端过滤逻辑部署位置及React+Spring Boot下拉列表方案选型
Hey Chris, let's walk through your two questions clearly—they're solid considerations for your React + Spring Boot LAN app!
Backend filtering logic should live on your Spring Boot backend service, specifically in either:
- The service layer: This is where you'd implement business-focused filtering rules (e.g., applying access controls, combining multiple data sources before filtering).
- The repository/data access layer: For database-level filtering, you'd write targeted queries (JPQL, native SQL, or use Spring Data JPA specs) to filter data at the source, which is far more efficient than pulling all data to the backend and filtering there.
The key reason here is centralization: keeping filtering logic on the backend means you only maintain it in one place, avoid duplicating logic across frontend components, and ensure consistent filtering behavior no matter which client (web, mobile, etc.) accesses the data. Even in a LAN with negligible latency, backend filtering reduces unnecessary data transfer and leverages server/database resources better than frontend filtering.
Since your dialog is rarely opened and LAN latency is a non-issue, both approaches work—but let's weigh their pros and cons for your scenario:
Option ①: Dedicated endpoint for the dropdown
- Pros: Super straightforward to build and maintain. You can create a targeted endpoint like
GET /api/dialog/filter-dropdown-optionsthat accepts exactly the UI input parameters it needs, and returns the formatted dropdown data directly. Debugging is easier because the logic is isolated, and frontend code stays clean with a simple API call. - Cons: If you end up adding more similar dynamic dropdowns later, you might end up with a bunch of one-off endpoints, which can clutter your API over time.
Option ②: Generic filtering endpoint
- Pros: Highly reusable. A single endpoint (e.g.,
POST /api/filter/generic) can handle multiple filtering use cases—you'd send a payload describing what data you need (like dropdown type, filter rules) and the backend returns the appropriate results. This keeps your API surface smaller if you have many dynamic data needs. - Cons: The logic is more complex to build upfront. You'll need to handle varied input payloads on the backend, and frontend code will have to construct more detailed requests. Debugging edge cases can be trickier since the endpoint has to handle multiple scenarios.
My recommendation
Go with Option ① for now. Since the dialog is rarely used, you won't suffer from any performance issues, and the simplicity of a dedicated endpoint will save you development time and make future maintenance easier. If you later find yourself needing multiple similar dynamic dropdowns, you can refactor into a generic endpoint then—no need to over-engineer upfront!
内容的提问来源于stack exchange,提问作者Chris

