@RequestParam

@Controller
public class StudentAdmissionController {

    @RequestMapping(value="/admissionForm.html", method = RequestMethod.GET)
    public ModelAndView getAdmissionForm() {

        ModelAndView model = new ModelAndView("AdmissionForm");

        return model;
    }

    // @RequestMapping("/submitAdmissionForm.html")
    // public ModelAndView submitAdmissionForm(@RequestParam(value="studentName", defaultValue="ABC") String name, @RequestParam("studentHobby") String hobby) {

    //     ModelAndView model = new ModelAndView("AdmissionSuccess");
    //     model.addObject("msg","Details submitted by you:: Name: "+name+ ", Hobby: " + hobby);

    //     return model;
    // }

    //如果传入的参数很多, 可以使用map来代替
    @RequestMapping(value="/submitAdmissionForm.html", method = RequestMethod.POST)
    public ModelAndView submitAdmissionForm(@RequestParam Map<String,String> reqPar) {

        String name = reqPar.get("studentName");
        String hobby = reqPar.get("hobby");

        ModelAndView model = new ModelAndView("AdmissionSuccess");
        model.addObject("msg","Details submitted by you:: Name: "+name+ ", Hobby: " + hobby);

        return model;
    }
}