@Controller
@RequestMapping(value="/us")
public class MyController {
@RequestMapping(value="/click",method = RequestMethod.POST)
public String hello2(User user){
System.out.println(":"+user);
return "result";
}
}
package domain;
public class Address {
private String city;
public String getCity() {
return city;
}
public Address() {}
/**
* @param city
*/
public Address(String city) {
super();
this.city = city;
}
@Override
public String toString() {
return "Address [city=" + city + "]";
}
public void setCity(String city) {
this.city = city;
}
}
package domain;
public class User {
private String username;
private String sex;
private Integer age;
private Address address;
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action ="us/click" method="POST">
姓名<input type="text" name="username" value="xiaom"/><br>
性别<input type="text" name="sex" value="female"/><br>
年龄<input type="text" name="age" value="18"/><br>
地址<input type="text" name="address.city" value="HenNa"/><br>
<input type="submit" value="提交"/>
</form>
</body>
</html>