【Struts2复习知识点九】-ModelDriven接收参数

UserAction.java

View Code
import com.bjsxt.struts2.user.model.User;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class UserAction extends ActionSupport implements ModelDriven<User>{

private User user = new User();

public String add() {
System.out.println("name=" + user.getName());
System.out.println("age=" + user.getAge());
return SUCCESS;
}

@Override
public User getModel() {
return user;
}

}

访问:<a href="user/user!add?name=a&age=8">


此方法不常用。

实现ModelDriven接口后,后自动调用getModel方法  然后将值注入到dto中

posted @ 2012-02-22 13:31  濤叔  阅读(239)  评论(0编辑  收藏  举报