How controller receives the data submitted by the page form in spring MVC

Source: Internet
Author: User

1. Define a class that contains the values for the name of all input in the form and generates getter and setter methods for the corresponding fields in the class

2, in the corresponding controller function, add an object of the class as a parameter.

Examples are as follows:

Front Page form:



The form's corresponding class is defined as follows: (Of course, the class can also contain other fields, but must contain the name value from all input in the form and generate getter and setter methods for it)



Add an object of the class to the parameter of the corresponding controller function:



We can then use the method in the Oval box to retrieve the data submitted by the form. Isn't it convenient?


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.