Front-to-back process: front desk jsp, background: Controller layer,service business layer,DAO data access layer, database model layer.
From the above process, the foreground JSP data, want to participate in the background of business logic operations, the key is to first put the foreground JSP data to the backstage controller. This key point involves a term called " binding Parameters " (or " bound data "), that is, how to bind the data in the foreground JSP to the parameters of the method in the background controller class.
In Springmvc, the "binding parameters" process requires a front-end JSP and a backend controller to be completed together:
1, the front desk JSP needs to do: Provide input box <input type= "text" name= "UserName" > or drop-down box <select name= "Province" > or radio box <input type= "Radio" name= "Sex" > or check box <checkbox name= "Hobbies", which is used to save multiple data entered by the user, This type of page tag element must be prefixed with the name attribute, indicating that this data is set as the request parameter (Request.setparameter ("UserName", user-entered user name), all encapsulated in the request, Then send a controller to the backend;
2, backstage controller needs to do: Controller receives request, automatically through Getrequest.getparameter ("UserName"), Request.getparameter ("sex") ... To remove multiple request parameters, how do you know which request parameter corresponds to which parameter of the method in the Controller class? This requires annotation @RequestPam: Before each parameter of the method in the Controller class, be sure to add the annotation @requestparam (value= "UserName", Required=false).
The above two steps completed, the successful completion of the "binding parameters"-the foreground JSP data, passed to the backend controller.
SPRINGMVC, front-end JSP package parameters, binding parameters, passing parameters to the background controller process detailed 123