Struts2.0深入学习 命名空间,模型驱动,表单重复提交
2009-09-06 00:00:00 来源:WEB开发网在页面form的action中也要加上/mynamespase并且还要加上后缀action(不管是不是用的struts标签)
3,模型驱动
/**
* 模型Bean
* @author 张明学
*
*/
public class RegisterBean {
private String username;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
Action则要接实com.opensymphony.xwork2.ModelDriven接口:
public class RegisterAction extends ActionSupport implements ModelDriven {
/**
* 模型驱动,该模型Bean必须实例化
*/
private RegisterBean loginBean = new RegisterBean();
public Object getModel() {
return loginBean;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
更多精彩
赞助商链接