Skip to content

Instantly share code, notes, and snippets.

@shashperera
shashperera / gist:0f75e9b5d29e5a1b973367e4bf72e56c
Created December 13, 2025 15:54
A gist about @PostMapping and @RequestParam (Spring Boot) - This is useful for handling form submissions or API calls with parameters in Spring Boot REST controllers.
// Example: Using @PostMapping with @RequestParam in Spring Boot
@RestController
public class MyController {
// Handles POST /greet?name=John&id=5
@PostMapping("/greet")
public String greet(
@RequestParam String name, // required param
@RequestParam(defaultValue = "0") int id, // optional param with default