🧬 Spring Boot – @PathVariable vs @RequestParam Today I learned how to handle data coming through URLs in Spring Boot APIs. 🧠 Key Concepts: ✔️ "@PathVariable" – Used to capture values from the URL path (e.g., "/user/10") ✔️ "@RequestParam" – Used to capture query parameters (e.g., "/search?name=Rony") 💡 Understanding the difference: • PathVariable → for specific resources (like user by ID) • RequestParam → for filtering or searching data 🔁 Real Flow: Frontend → URL → Controller → Extract value → Process → Response 💻 DSA Practice: • Counting vowels in a string • Reversing words in a sentence ✨ Learning how to handle request data effectively is essential for building flexible and scalable REST APIs. #SpringBoot #Java #BackendDevelopment #RESTAPI #WebDevelopment #DSA #LearningInPublic #SoftwareEngineering
Spring Boot PathVariable vs RequestParam
More Relevant Posts
-
@PathVariable vs @RequestParam – Passing URL Data While working on my Spring Boot projects, I explored how to pass data through URLs using @PathVariable and @RequestParam, and how both are used in different scenarios. 🔹 @PathVariable Used to get values directly from the URL path. It is mostly used when the value is required and represents a specific resource. Example: /users/101 → here 101 is taken as path variable 🔹 @RequestParam Used to get values from query parameters in the URL. It is commonly used for optional data like filters, search, or pagination. Example: /users?name=Rahul → here name is a request parameter Why use both? Using @PathVariable and @RequestParam properly makes APIs more clear and meaningful. @PathVariable → for identifying resources @RequestParam → for filtering or optional inputs In real projects, understanding this difference helps in designing clean and scalable REST APIs. #SpringBoot #Java #BackendDevelopment #RESTAPI #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
#Post3 In the previous post, we understood the role of @RestController in building APIs. Now the next step is 👇 How do we map HTTP requests to methods? That’s where mapping annotations come in 🔥 In Spring Boot, we use: • @GetMapping → for GET requests • @PostMapping → for POST requests • @PutMapping → for UPDATE • @DeleteMapping → for DELETE • @PatchMapping → for partial updates Example: @GetMapping("/users") → fetch all users @PostMapping("/users") → create a new user 💡 What about @RequestMapping? @RequestMapping is a generic annotation that can handle all HTTP methods. Example: @RequestMapping(value="/users", method=RequestMethod.GET) 👉 But in modern Spring Boot, we prefer specific annotations like @GetMapping for cleaner and readable code Key takeaway: Use specific mapping annotations for better clarity and maintainability 👍 In the next post, we will understand how @RequestBody works in handling request data 🔥 #Java #SpringBoot #BackendDevelopment #RESTAPI #LearnInPublic
To view or add a comment, sign in
-
Learning and implementing REST APIs with Spring Boot What's happening here: @RestController :- marks this class as a REST API handler @RequestMapping("/employee") :- base URL for all endpoints @Autowired :- injects the Service layer dependency GET /display :- a simple test endpoint to verify the API is live POST /save :- accepts Employee data as JSON and saves to DB GET /getAll :- fetches all employee records from the database Implementing Dependency Injection and a structured Layered Architecture has highlighted the importance of writing clean, maintainable code. #REST #API #BackendDevelopment #SpringBoot #Java
To view or add a comment, sign in
-
-
-:Improving API Performance in Spring Boot :- Optimizing APIs in Spring Boot is crucial for building scalable and high-performance backend systems. Here are some practical techniques that made a real difference in my projects: ✔ Use Caching (@Cacheable) Reduce repeated DB calls using Spring Cache with Redis/EhCache. ➡️ @Cacheable, @CacheEvict can significantly cut response time. ✔ Optimize Database Access (JPA/Hibernate) • Use proper indexes • Avoid N+1 queries • Use DTO projections instead of fetching full entities ✔ Connection Pooling (HikariCP) • Spring Boot uses HikariCP by default — tune pool size for better throughput. ✔ Pagination Instead of Large Responses Use Pageable to limit data returned per request. ✔ Lazy Loading & Fetch Strategies Avoid unnecessary data fetching using FetchType.LAZY. ✔ Actuator + Monitoring Track performance using Spring Boot Actuator ✔ API Rate Limiting Use tools like Bucket4j to prevent overload. What’s your technique for improving Spring Boot performance? comment here 👇 #SpringBoot #Java #Backend #API #Performance #Microservices #Hibernate #Coding #Tech
To view or add a comment, sign in
-
🚀 Spring Boot – User API Upgrade (Full CRUD) Took my mini project to the next level by implementing complete CRUD operations in Spring Boot. 🧠 What I added: ✔️ GET "/users" → Fetch all users ✔️ PUT "/user/{id}" → Update user ✔️ DELETE "/user/{id}" → Delete user 💡 Now the API supports full lifecycle operations: Create • Read • Update • Delete 🔁 Architecture in action: Controller → Service → In-memory data → JSON response 🧪 Tested all endpoints using Postman and verified the complete flow. ⚠️ Also understood the importance of proper error handling (next step: exception handling instead of returning null). 💻 DSA Practice: • Move zeros to end (array manipulation) • First non-repeating character (HashMap concept) ✨ This step helped me understand how real backend systems manage and manipulate data efficiently. #SpringBoot #Java #BackendDevelopment #RESTAPI #CRUD #DSA #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
I was building filtering for financial records in my backend. Date range. Category. Amount range. User scope. All optional. All combinable. I started with hardcoded query logic using if-else conditions for different filter cases. It got messy fast. Every new filter meant rewriting existing logic. At one point, the queries looked like they were never meant to be read again. So I scrapped it. I implemented the Specification pattern using Spring Data JPA. Each filter became an isolated, composable predicate. At runtime, only the active ones combine into a single query. No hardcoding. No duplication. Small change in approach. Big impact on scalability and future scope. Now, adding a new filter is just one addition. Existing logic doesn't change. This is the Open/Closed principle from SOLID in practice, open for extension, closed for modification. Each Specification also owns exactly one filter concern. Single Responsibility, naturally enforced. The filtering layer went from something I avoided touching to something I can extend confidently, without regression risk. Interesting how backend complexity shifts as systems grow: performance → security → maintainability. This was firmly the third. #Backend #Java #Maintainability #SOLID #LearningInPublic #SWE
To view or add a comment, sign in
-
Recently, I focused on applying Data Structures & Algorithms to real backend problems in my Spring Boot Work Order Management system. The goal was simple: build APls that are not just functional, but also fast, scalable, and efficient under load. ✅ 𝐖𝐡𝐚𝐭 𝐈 𝐰𝐨𝐫𝐤𝐞𝐝 𝐨𝐧 🔷 𝐂𝐚𝐜𝐡𝐢𝐧𝐠 𝐒𝐭𝐫𝐚𝐭𝐞𝐠𝐲 - Introduced in-memory caching using @Cachable (Caffeine) for frequently accessed WorkOrder data. 🔷 𝐎𝐩𝐭𝐢𝐦𝐢𝐳𝐞𝐝 𝐀𝐠𝐠𝐫𝐞𝐠𝐚𝐭𝐢𝐨𝐧 - Used prefix computation to avoid redundant iterations while calculating monthly maintenance cost. 🔷 𝐅𝐚𝐬𝐭𝐞𝐫 𝐋𝐨𝐨𝐤𝐮𝐩𝐬 - Leveraged HashSet for O(1) lookups during status filtering. 🔷 𝐑𝐞𝐝𝐮𝐜𝐞𝐝 𝐃𝐁 𝐂𝐚𝐥𝐥𝐬 - Smart data retrieval + caching reduced unnecessary database round-trips. 🔷 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞 𝐈𝐦𝐩𝐚𝐜𝐭 - Better response times, lower DB load, and more consistent performance under scale. DSA isn't just for interviews. It directly influences how we design APls, reduce latency, and handle scale in production systems. Sharing some implementation snippets and results below #Java #SpringBoot #BackendDevelopment #ADINacian #DerformanceOntimization #DS4
To view or add a comment, sign in
-
-
Daily SQL Question #5: Why Your Feed API Gets Slower Over Time Scenario You’re building a social platform in LinkedIn / X style. Backend stack: - Java + Spring Boot - PostgreSQL - millions of rows in posts - users endlessly scroll feeds To fetch page 5001, the API runs: ``` SELECT * FROM posts ORDER BY created_at DESC LIMIT 20 OFFSET 100000; ``` Initially everything looks fine. Months later: - feed API becomes slower - DB CPU climbs - cache hit ratio drops - p95 latency spikes - connection pool saturation starts appearing https://lnkd.in/eF_gppur
To view or add a comment, sign in
-
-
We've been building something quietly for a while, and I'm ready to share it. OpenTaint is an open-source taint analysis engine with the most thorough Spring Boot support. https://lnkd.in/darQ5ZRN Not "Java support." Actual modeling of how Spring works. Spring Boot's annotation-driven architecture creates data flows that are invisible to conventional static analysis. A bean injection crosses class boundaries with no call site in the source. JPA persistence links two HTTP endpoints through the database with no shared code path. A Freemarker configuration object determines whether user input reaching template.process() is exploitable — or harmless. These are not edge cases. This is the default architecture of most Java web applications. OpenTaint traces tainted data through every layer: - Following data across file and class boundaries — through DTO field access and method chains. - Resolving configuration-aware sinks — tracing through DI to determine whether a resolver or handler is actually exploitable. - Connecting endpoints through persistence — where the database or service state is the only link. - Distinguishing dangerous fields from safe ones — at per-column granularity within those flows. The engine operates on bytecode, resolves virtual dispatch, and maps every finding back to its HTTP endpoint. If you're using Semgrep or CodeQL on your Java/Kotlin/Spring codebase — try OpenTaint on the same project and compare what it finds. We've published reproducible comparisons on the blog, but seeing it on your own code is more convincing. Apache 2.0 + MIT. Engine, rules, CLI, GitHub Action, GitLab CI — everything is open source. #java #kotlin #spring #springboot #security #appsec #opensource #sast #taintanalysis
To view or add a comment, sign in
-
-
Understanding Request Mapping in Spring Boot While working on my Spring Boot projects, I explored how request mapping plays a crucial role in handling client requests efficiently. 🔹 @RequestMapping This is a general-purpose annotation used to map HTTP requests to handler methods. It can be applied at both class and method level and supports multiple HTTP methods. 🔹 @GetMapping Specifically designed for handling HTTP GET requests. It makes the code more readable and is commonly used for fetching data from the server. 🔹 @PostMapping Used for handling HTTP POST requests. Ideal when sending data from client to server, such as form submissions or creating new records. Why use specific mappings? Using @GetMapping, @PostMapping, etc., improves code clarity and makes APIs more expressive compared to using @RequestMapping for everything. In real projects, choosing the right mapping annotation helps in building clean and maintainable REST APIs. #SpringBoot #Java #BackendDevelopment #RESTAPI #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development