🚀 Day 46: Mastering Data Binding in Spring MVC Continuing my Java Developer journey! Today was all about understanding how data moves from the frontend to my controllers and back. I spent the day diving deep into Spring MVC’s data handling capabilities. Here’s a breakdown of what I covered: @RequestParam vs. @PathVariable: Learned when to use Query Parameters (e.g., ?id=101) versus Path Variables (e.g., /user/101) to capture dynamic data from URLs. Data Binding (1-Way & 2-Way): 1-Way: Passing data from the Controller to the View using the Model object. 2-Way: Using Spring’s form handling to keep the View and the Model in sync, making form submissions seamless. Spring Tag Library: Explored how to use specialized JSP tags to bind form elements directly to Java objects, reducing boilerplate code and improving type safety. Seeing these pieces click together makes building web applications feel much more intuitive. Onward to Day 47! 👨💻 #Java #SpringFramework #SpringMVC #WebDevelopment #Backend #JavaDeveloper #LearningJourney #CodingLife #Telusko Hyder Abbas Naman Pahariya
Shivsharan Yadav’s Post
More Relevant Posts
-
Real world projects in production... At Architectural level - Java (Spring boot) 1) AOP implementation 2) Cache management 3) Interceptor 4) Global exception handling 5) Thread management 6) database integration 7) Microservices communication At Architectural level - Angular 1) Microfrontend communication. (using Module federation) 2) shared library to share components , directives between different microfrontends. 3) proxy file (CORS) to connect with backend (Java) 4) Generic components 5) cache management 6) Prevention from different attacks like... XSRF, XSS etc. At service level (Java): 1) Always use Composition over inheritance 2) Validations like @notnull, @notEmpty etc.. 3) use of var keyword 4) memeory leak prevention through weakHashMap 5) MVC: creating a controller , model, repository and service file. 6) use of virtual threads for multi-Threaded Environment. 7) Use of signals instead of traditional approach of for loop iterations. At Component Level (Angular) 1) creating directives and pipes. 2) use of scss for styling different components 3) use of structural directives @If, @for track: trackId 4) use of @defer for lazy loading of components 5) routing file for different routes let say /home, /dashboard, /user/:id etc... 6) standalone components 7) Use of Signals for forms and reactive programming 8) Interpolation 9) two way binding through ngModel Integration of frontend and backend and database is done with 1) At frontend (Angular) , field--> target: 'http://localhost:8080' in proxy.json file. (let's say your backend Java is running on localhost:8080) 2) At backend (Java) , application.properties file has i) base URL /api (org/system name), ii) server.port=8080 iii) database url: spring.datasource.url=jdbc:mysql://localhost:3306/your_db_name (let's say mySQL is running on localhost:3306.) Hope this helps! 😊 #architecture #angular #integration #realworldprojects #productionscale #java #springboot #javafullstack #springboot #mysql #latestfeatures
To view or add a comment, sign in
-
File Uploads and Retrieval in Spring Boot Master file management in modern web applications by exploring File Uploads and Retrieval in Spring Boot. Handling binary data is a core requirement for enterprise systems, and this guide provides a deep dive into building a robust solution using REST controllers and the MultipartFile interface. Following a "core-to-shell" approach, you’ll learn to integrate foundational Java NIO operations with high-level Spring APIs to create a seamless bridge between raw disk storage and your frontend. Discover how to implement secure uploads and efficient file fetching while maintaining a clean, scalable microservices architecture. => Multipart Management: Efficiently process file streams with Spring Boot. => Java NIO Mastery: Use modern I/O for high-performance file handling. => RESTful Fetch: Implement endpoints for secure content retrieval. https://lnkd.in/gyQvP5QA #SpringBoot #spring #springframework #springbootdeveloper #Maven #Java #java #JAVAFullStack #RESTAPI #Microservices #BackendDev #JavaNIO #FileUpload #WebDevelopment #CodingTutorial #codechallenge #programming #CODE #Coding #code #programmingtips
To view or add a comment, sign in
-
🚀 Day 19 – map() vs flatMap() in Java Streams While working with Streams, I came across a subtle but important difference: "map()" vs "flatMap()". --- 👉 map() Transforms each element individually List<String> names = Arrays.asList("java", "spring"); names.stream() .map(String::toUpperCase) .forEach(System.out::println); ✔ Output: JAVA, SPRING --- 👉 flatMap() Flattens nested structures List<List<Integer>> list = Arrays.asList( Arrays.asList(1, 2), Arrays.asList(3, 4) ); list.stream() .flatMap(Collection::stream) .forEach(System.out::println); ✔ Output: 1, 2, 3, 4 --- 💡 Key insight: - "map()" → 1-to-1 transformation - "flatMap()" → 1-to-many (and then flatten) --- ⚠️ Real-world use: "flatMap()" is very useful when dealing with: - Nested collections - API responses - Complex data transformations --- 💡 Takeaway: Understanding when to use "flatMap()" can make your stream operations much cleaner and more powerful. #Java #BackendDevelopment #Java8 #Streams #LearningInPublic
To view or add a comment, sign in
-
💡 Types of Dependencies in Spring Framework: In the 🌱 Spring Framework, Dependency Injection (DI) is a core concept that helps achieve loose coupling and better code maintainability. Let’s explore the three main types of dependencies used in Spring: 🔹 1. Primitive Dependency This involves injecting simple values like int, double, boolean, or String. 👉 Example: Injecting a username, age, or configuration value into a bean. ✔️ Configured using @Value annotation or XML ✔️ Commonly used for constants and environment properties ✔️ Lightweight and easy to manage 💡 Use case: Application properties like app name, port number, etc. 🔹 2. Collection Dependency Spring allows injecting collections such as List, Set, Map, or Properties. 👉 Example: List of email recipients Map of key-value configurations ✔️ Supports bulk data injection ✔️ Can be configured via XML or annotations ✔️ Useful for dynamic and flexible data handling 💡 Use case: Storing multiple values like roles, configurations, or URLs. 🔹 3. Reference Dependency (Object Dependency) This is the most important type where one bean depends on another bean. 👉 Example: OrderService depends on PaymentService Car depends on Engine ✔️ Achieved using @Autowired, @Inject, or XML <ref> ✔️ Promotes loose coupling ✔️ Core concept behind Spring IoC Container 💡 Use case: Service layer calling repository layer, or controller calling service. 🚀 Why Dependency Injection Matters in Spring? Reduces tight coupling between classes Makes unit testing easier Improves code reusability and maintainability Enables better separation of concerns 🔥 Pro Tip: Prefer constructor injection over field injection for better immutability and testability. #SpringFramework #Java #DependencyInjection #BackendDevelopment #SoftwareEngineering #TechLearning Anand Kumar Buddarapu
To view or add a comment, sign in
-
-
I've seen developers write 200 lines of config code. All of it could've been replaced with 3 annotations. That's the power of Spring Boot — if you know the right annotations. Most developers only scratch the surface. Here's the complete breakdown you actually need: BOOTSTRAP → @SpringBootApplication — main entry point, enables everything → @EnableAutoConfiguration — auto-configures beans from classpath → @ComponentScan — scans and registers Spring components LAYERED ARCHITECTURE → @Component — generic Spring-managed bean → @Service — business logic layer → @Repository — data access with exception translation → @RestController — builds REST APIs returning JSON/XML DEPENDENCY INJECTION → @Autowired — injects dependencies automatically → @Qualifier — resolves ambiguity between multiple beans → @Primary — marks default bean implementation WEB & REST APIs → @GetMapping / @PostMapping / @PutMapping / @DeleteMapping → @RequestBody — maps payload to Java object → @PathVariable — extracts values from URL → @RequestParam — reads query parameters DATABASE & JPA → @Entity — maps class to DB table → @Transactional — ensures atomic operations with rollback → @GeneratedValue — auto-generates primary key VALIDATION → @Valid — triggers validation on request → @NotNull / @NotBlank / @Email / @Pattern — enforce input rules EXCEPTION HANDLING → @ExceptionHandler — handles specific exceptions → @RestControllerAdvice — global error handling for REST APIs SECURITY → @EnableWebSecurity — enables Spring Security → @PreAuthorize — role/permission check before method execution ADVANCED → @Scheduled — runs cron jobs → @Async — executes methods asynchronously → @Cacheable / @CacheEvict — cache and invalidate results I've compiled all of this into a structured PDF carousel. Comment SPRING and I'll send it to your DMs. ♻ Repost if this helped someone on your network. Follow Narendra K. for more Java & Spring Boot content. #SpringBoot #Java #BackendDevelopment #JavaDeveloper #SpringFramework #SoftwareEngineering #WebDevelopment #Programming #InterviewPreparation
To view or add a comment, sign in
-
🚨 Java is finally fixing “final” — and it’s a BIG deal for backend devs For years, we trusted this: final String name = "Alok"; 👉 Meaning: this value will never change But under the hood… that wasn’t always true 😶 Using reflection: Field f = User.class.getDeclaredField("name"); f.setAccessible(true); f.set(user, "Hacked"); 💥 Your "final" field could still be modified No error. No warning. (Yes, since JDK 5!) --- 🤯 Why was this allowed? Because popular frameworks relied on it: • Jackson / Gson → deserialization • Hibernate → entity hydration • Mockito → mocking • Old DI → field injection 👉 Reflection made it possible to break immutability --- 🚨 What’s changing now? With Java 26 (JEP 500): ➡️ “Prepare to Make Final Mean Final” ✔️ Today: You’ll see warnings ❌ Tomorrow: It will be blocked (error) --- ⚠️ Why this matters This is not just syntax — it impacts: 🔹 Thread safety (immutability = safe concurrency) 🔹 JVM optimizations (compiler trusts "final") 🔹 Security (no hidden mutation) --- 🛠️ What you should do NOW ✅ Prefer constructor injection private final Service service; public MyClass(Service service) { this.service = service; } ✅ Use immutable DTOs (Java Records) public record UserDTO(String name, int age) {} ✅ Update libraries (Jackson, Hibernate, Mockito) ✅ Run your app on newer Java & check warnings --- 💡 Final Thought 👉 “final” was never truly final… until now. And honestly — it’s about time. --- #Java #SpringBoot #Backend #JavaDeveloper #CleanCode #JVM #Programming #SoftwareEngineering
To view or add a comment, sign in
-
⚠️ Hot Reload in Spring Boot Isn’t Magic. It’s ClassLoader Isolation. When you change code and see: 👉 App restarts in seconds 👉 No full JVM restart What’s really happening? 1️⃣ Two ClassLoaders — The Core Idea Spring Boot DevTools splits your app into: Base ClassLoader → dependencies (stable) Restart ClassLoader → your application code (changing) 2️⃣ Why This Matters Dependencies (like Spring, Hibernate): Loaded once Heavy to reload Rarely change Your code: Changes frequently Needs fast reload So only your code is reloaded. 3️⃣ What Happens on Code Change You modify a .class file DevTools detects change (file watcher) Discards Restart ClassLoader Creates a new one Reloads your classes Base ClassLoader stays untouched 4️⃣ Why It’s Faster Than Full Restart Without DevTools: JVM restarts All classes reloaded Framework reinitialized With DevTools: Only your classes reload Dependencies reused Startup drastically reduced 5️⃣ What Actually Gets Restarted? Spring ApplicationContext Beans created again Config reloaded But: 👉 JVM process stays alive 👉 Core libraries remain loaded 6️⃣ Common Gotcha (Very Important) Static state survives in Base ClassLoader. Example: static Map cache = new HashMap(); If loaded by base loader: It won’t reset after reload Leads to weird bugs 7️⃣ Why Some Changes Don’t Reload DevTools won’t reload when: Dependency JAR changes Config outside classpath changes Native resources updated Requires full restart 8️⃣ Comparison With Other Tools Tool Approach DevTools ClassLoader restart JRebel Bytecode rewriting HotSwap Limited JVM replacement DevTools doesn’t “reload classes” It replaces the ClassLoader that loaded them #Java #SpringBoot #JVM #ClassLoader #HotReload #BackendEngineering #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
Java 17 Feature: Record Classes What is a Record Class? A record class is mainly used to create DTOs (Data Transfer Objects) in a simple and clean way. Why DTOs? DTOs are used to transfer data: • Between services • From backend to frontend Key Features of Record Classes: Immutable by default (data cannot be changed after creation) Less code (no need to write getters, constructors, etc.) When you create a record, Java automatically provides: Private final fields All-arguments constructor Getter methods (accessor methods) toString(), equals(), hashCode() Example: public record Customer(int customerId, String customerName, long phone) {} Usage: Customer customer = new Customer(1011, "John", 9890080012L); System.out.println(customer.customerId()); Important Points: Record class is implicitly final Cannot extend other classes Internally extends java.lang.Record Can implement interfaces (normal or sealed) Can have static methods and instance methods Cannot have extra instance variables With Sealed Interface: public sealed interface UserActivity permits CreateUser, DeleteUser { boolean confirm(); } public record CreateUser() implements UserActivity { public boolean confirm() { return true; } } Before Java 17: We used Lombok to reduce boilerplate code. After Java 17: Record classes make code: Cleaner Shorter Easier to maintain #Java #Java17 #BackendDevelopment #FullStackDeveloper #Programming #SoftwareEngineering
To view or add a comment, sign in
-
Your Spring Boot API is slow. Not because of bad code. Because of invisible garbage. A simple request like GET /api/users/123 looks harmless. But Spring Boot creates a storm of temporary objects you never see: → Tomcat builds request/response objects → Spring Security creates SecurityContext → Filters wrap everything in decorators → Hibernate creates lazy-load proxies → Dirty checking snapshots entity state → Jackson builds serialization objects → @Transactional wraps services in proxies You wrote 15 lines. The framework created thousands of objects. At 100 RPS? Fine. At 1,000 RPS? Disaster. Young Gen fills every second GC runs constantly p99 latency spikes CPU burns on cleanup, not business logic No crash. No exception. Just mysteriously slow performance. ━━━━━━━━━━━━━━━━ How I reduce object creation: Return DTOs, not entities Use @Transactional(readOnly = true) for reads Use log placeholders: log.info("User {}", id) Prefer primitives (int vs Integer) in hot paths Avoid streams/maps in performance-critical loops Tune JVM Young Gen size Profile with Java Flight Recorder ━━━━━━━━━━━━━━━━ The real performance truth: The fastest code isn't code that executes the fastest. It's code that creates the least garbage. Master this, and your APIs will scale. What's your go-to optimization for high-traffic Spring Boot apps? #SpringBoot #Java #Microservices #BackendDevelopment #SoftwareArchitecture
To view or add a comment, sign in
-
-
Java Spring Boot Annotations in a Nutshell https://lnkd.in/g7BmyE3E A technical overview of the essential Java Spring Boot Annotations, serving as a comprehensive "nutshell" guide for modern backend development. As Spring Boot continues to dominate the enterprise ecosystem, mastering its annotation-driven configuration is critical for building scalable, decoupled, and maintainable microservices. => Core Framework Annotations: Analyzing @SpringBootApplication, @Component, and @Bean for managing application context and dependency injection. => Web and REST Integration: Demonstrating the use of @RestController, @RequestMapping, and @PathVariable to streamline API development. => Data and Configuration: Leveraging @Service, @Repository, and @Value to enforce clean architectural layers and externalize properties. #codechallenge #programming #CODE #Coding #code #programmingtips #java #JAVAFullStack #spring #springframework #Springboot #springbootdeveloper #Maven #gradle #annotations #controller #service #dependencyInjection
To view or add a comment, sign in
More from this author
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