spring-mvc @RequestParam


Example

@Controller
public class EditPetForm {

    @RequestMapping("/pets")
    public String setupForm(@RequestParam("petId") int petId, ModelMap model) {
        Pet pet = this.clinic.loadPet(petId);
        model.addAttribute("pet", pet);
        return "petForm";
    }
}

Important to mention, but pretty obvious, is that @RequestParam is intended to work when using HTTP GET method only because only with GET you can send a query string with parameters, and @RequestParam you can bind parameters in the query string to your controller handler parameters.