几种JSP从Action中取值的方法 https://blog.csdn.net/qq_42192693/article/details/88836223
一,Action是模型驱动
<form action="select" method="post">
<input type="text" name="name" /> <input type="text"
name="number" /> <input type="submit" value="提交">
</form>
package Action;
import com.opensymphony.xwork2.ModelDriven;
import Bean.Student;
public class SelectAction implements ModelDriven<Student> {
private Student student = new Student();
public Student getModel() {
return student;
}
public String execute() {
return "success";
}
}
二,Action是JavaBean类型
<form action="select" method="post">
<input type="text" name="student.name" /> <input type="text"
name="student.number" /> <input type="submit" value="提交">
</form>
package Action;
import com.opensymphony.xwork2.ModelDriven;
import Bean.Student;
public class SelectAction {
private Student student;
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public String execute() {
return "success";
}
}
三,Action是属性内置
<form action="select" method="post">
<input type="text" name="name" /> <input type="text"
name="number" /> <input type="submit" value="提交">
</form>
package Action;
public class SelectAction {
private String name;
private String number;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String execute() {
return "success";
}
}