action文件:
public class HelloWorldAction {//id=123&name=aaa
private Integer id;
private Person person;
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
实体bean文件:
public class Person {
//需要默认构造器,struts2利用反射机制获得值
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
private String name;
private Integer id;
}
浏览器请求页面:
<form action="<%=request.getContextPath() %>/control/department/helloWordexecute.action">
<!-- <form action="/control/department/helloWordexecute.action"> -->
name:<input type="text" name="person.name">
id:<input type="text" name="person.id">
<input type="submit" value="send">
</form>
接受实体bean 值文件:
<body>
id=${person.id}<br>
name=${person.name}
</body>