前言:
前面已经有一篇随笔介绍了Struts2的大概原理。本文就Struts2中Action与jsp页面进行数据对接时介绍几种常见方法!
-
值栈ValueStack
-
3个Action
Action1
View Codepackage com.gdufe.action; import com.opensymphony.xwork2.ActionSupport; /* * Action接收参数之后通过set方法赋给普通变量age,name; */ public class UserAction1 extends ActionSupport{ private int age; private String name; public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String execute(){ return SUCCESS; } public String test(){ System.out.println(age +"|"+ name); return SUCCESS; } }