SPRING-MVC---controller parameter binding type

Source: Internet
Author: User
Tags tag name

Type of controller parameter binding

   The controller has 6 types of binding parameters. No parameters (system default type), Simple Type (intager,double), Pojo Class (object), array, set, HashMap, etc.

We use an example to express it in code:

Users (UID,UNAME,UPASS,BIRTHDAY,CID)

Province (Cid,cname)

1) without parameters, the query does not require parameters, such as querying all user information. (Two-table connection query) Findallusers, There are several ways to accept data, and carry parameters to jump to other pages. This is detailed in the previous section. It's not going to show up here.

         

2) Simple type. Here I'm using Intager, passing in an ID to delete a user. Note:the UID self-break is the same as the Name property of the JSP page get value.

      

3) a Pojo type. Pass in an object, set the object ID, query the user information by ID, Note:the tag name passed in the JSP page is the same as the database field

      

4) incoming number group, int type, implement bulk delete. Note: The parameter uid must be the same as the JSP page label Name property

      

5) Set: parameter is a string, with Ajax incoming, with jquery by the line local refresh, using the @requestmapping annotation 

1 /**2 * method that is specified by the Ajax method when the form's User name text box loses focus, @requestmapping the specified URL commits3 * 4 * @paramUESR5 * @return6 */7@RequestMapping (value = "/isvailduname", method = {8Requestmethod.post}, produces = "Application/json;charset=utf-8")9  Public@ResponseBodyintisvailduname (String uname) {TenUsersbean user =NewUsersbean (); One User.setuname (uname); A returnusersservice.haveusers (user); -}

      

Spring-mvc---The type of controller parameter binding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.