@RequestParam:
Annotation which indicates that a method parameter should be bound to a web request parameter.
Supported for annotated handler methods in Servlet and Portlet environments.
If the method parameter type is Map and a request parameter name is specified, then the request parameter value is converted to a Map assuming an appropriate conversion strategy is available.
Example
package com.candidjava.springmvc; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; @Controller public class CustomerController { @RequestMapping(value = "/customer.htm") public ModelAndView addCustomer(@RequestParam("txt_username") String txt_username, @RequestParam("txt_password") String txt_password) { ModelAndView model = new ModelAndView("page"); model.addObject("msg", "RequestMapping for URL Parameters username = " + txt_username + " and password = " + txt_password); return model; } // ***************************************** }
Screenshot:
Download