package model;
public class Person {
private String userName;
private String password;
@Override
public String toString(){return"Person{" +
"userName='" + userName + '\'' +
", password='" + password + '\'' +
'}';}
public String getUserName(){return userName;}
public void setUserName(String userName){
this.userName = userName;}
public String getPassword(){return password;}
public void setPassword(String password){
this.password = password;}}
1.2模型驱动action
package action;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;import model.Person;
public class PersonAction extends ActionSupport implements ModelDriven<Person>{
//必须要实例化不然取不到数据
private Person person=new Person();
@Override
public Person getModel(){return person;}
public String form(){
System.out.println(person);return SUCCESS;}}