struts.xml--------------------------------------------------------------------------------------------------------------------------------Action----------------------------------------------------------------package regist;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;public class RegistAction2 extends ActionSupport implements ModelDriven /successpage2.jsp { User user = new User(); @Override public User getModel() { return user; } @Override public String execute() throws Exception { System.out.println(user.getName()); return SUCCESS; } }----------------------------------------------------------------User.java------------------------------------------------------package regist;public class User{ private String name; private String age; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } }----------------------------------------------regist.jsp-------------------------------------------------- --------------------------------------------------result.jsp-------------------------------------------------- ${requestScope.name } ${requestScope.age } --------------------------------------------------
继属性模式的又一种更加符合面向对象风格的构建bean模型的一种action