@GetMapping and @PostMapping in Spring Boot (Examples)
@GetMapping maps HTTP GET requests and @PostMapping maps HTTP POST requests to controller methods in Spring. Both are shortcuts for @RequestMapping with a fixed HTTP method.
@GetMapping maps HTTP GET requests and @PostMapping maps HTTP POST requests to controller methods in Spring. Both are shortcuts for @RequestMapping with a fixed HTTP method.
Learn to create a REST API controller using @RestController in a Spring Boot application, and add method validation, error handling and unit tests.
Learn to create generic and custom error pages for specific HTTP error codes in a Spring Boot application with configuration examples.
Learn to use Spring WebMvcConfigurer to customize various aspects of Spring MVC, such as argument resolvers, view resolvers, exception handling, and more.
Learn about Spring @PathVariable and @RequestParam annotations and compare them with Jakarta’s @PathParam and @QueryParam annotations.
Starting Spring Framework 6.1 and Sring Boot 3.2, we can use the Spring RestClient for performing HTTP requests using a fluent and synchronous API. The RestClient works over the underlying HTTP client libraries such the JDK HttpClient, Apache HttpComponents, and others. As the name suggests, RestClient offers the fluent API design …
Learn about top 5 template engines for Spring MV applications, comparing their features and setup process, to make more informed decisions.
Learn why we need a custom validation annotation and how to create, use and test such a custom validation annotation in Spring MVC.
In this Spring boot with Angular tutorial, learn to create REST APIs using Spring boot and call from Angular to create a CRUD application.
Spring WebMVC (or Spring MVC) contains Spring’s model-view-controller (MVC) and REST Web Services implementation for web applications.
In Spring, @GetMapping maps HTTP GET requests and @PostMapping maps HTTP POST requests to controller methods. Both are shortcuts for @RequestMapping with a fixed HTTP method. See a working Spring Boot REST controller, the @RequestMapping equivalent and the attributes that narrow a mapping.
Build a contacts address book with Spring MVC, Hibernate 7 and Thymeleaf on Spring Boot 4: list, create, edit and delete pages, form validation, Post/Redirect/Get, and MockMvc and @DataJpaTest tests.
Spring Boot JSP example: add tomcat-embed-jasper and the Jakarta JSTL artifacts, set spring.mvc.view.prefix and suffix, use war packaging, and render a list page and a form with embedded Tomcat.
Spring HandlerInterceptor allows creating interceptors in Spring or Boot applications to handle requests pre- and post-controller methods.
A complete Spring MVC hello world application on Spring Boot 4.1.1 and Java 25: a @Controller with @RequestParam and @PathVariable, a Thymeleaf template, static CSS, MockMvc tests, and fixes for the Whitelabel 404/500 and “Circular view path” errors.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.