The data submitted in the form are all username=haha&password=123 in k=v format
The parameter binding process of SpringMVC binds the request parameters submitted by the form as the parameters of the method in the controller.
Requirement: The name of the submitted form and the name of the parameter are the same
Supported data types
Basic data types and string types
Entity type (JavaBean)
Collection data type (List, map collection, etc.)
37.5.2 Basic data types and string types
The name of the submitted form and the name of the parameter are the same
case sensitive
37.5.3 Entity Type (JavaBean)
The name of the submitted form and the attribute name in the JavaBean need to be consistent
If a JavaBean class contains other reference types, then the name attribute of the form needs to be written as: object. Attributes such as address.name
37.5.4 Encapsulate collection attribute data
JSP page writing method: list[0]. Attributes
Example:
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2018/4/29
Time: 22:10
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html><head><title>Title</title></head><body>
<%--把数据封装Account类中,类中存在list和map的集合--%>
<formaction="param/saveAccount"method="post">
姓名:<inputtype="text"name="username"/><br/>
密码:<inputtype="text"name="password"/><br/>
金额:<inputtype="text"name="money"/><br/>
用户姓名:<inputtype="text"name="list[0].uname"/><br/>
用户年龄:<inputtype="text"name="list[0].age"/><br/>
用户姓名:<inputtype="text"name="map['one'].uname"/><br/>
用户年龄:<inputtype="text"name="map['one'].age"/><br/><inputtype="submit"value="提交"/></form></body></html>
37.5.5 Solve the problem of Chinese garbled characters
Configure the filter to solve Chinese garbled in web.xml
Any data types submitted by the form are all string types, but the Integer type is defined in the background, and the data can also be encapsulated, indicating that the Spring framework will perform data type conversion by default.
If you want to customize the data type conversion, you can implement the Converter interface