What is a REST controller & Write a simple REST controller in Spring boot 3.xx
What is REST controller? REST stands for REpresentation State Transfer. A web controller is a logical component that is responsible for navigation of all operations related to a resource. If you have a ProductController in your application, this ProductController will be responsible for: - 1. Creating new product 2. Updating existing product 3. Deleting a product 4. Getting a product 5. Getting all products Write Product class package wealthManager.models; import java.io.Serializable; public class Product implements Serializable { private final String name ; private int price ; public Product (String name, int price) { this . name = name; this . price = price; } public void setPrice ( int price){ this . price = price; } public String getName () { return name ; } public int getPrice () { return price ; } } Write ProductController class package wealthManager.rest; import jakarta.annotation. PostConstruct ; im...
Comments
Post a Comment
Share your thoughts here...