0 sturts2 验证框架<二> 13年前 2.注册成功欢迎页面welcome.jsp Java代码 congratulations!${user.userName} <br> congratulations!${user.userName} <br> 3.注册处理action RegisterAction Java代码 package org.kingtoon.action; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import org.kingtoon.bean.User; import com.opensymphony.xwork2.ActionSupport; public class RegisterAction extends ActionSupport { private User user; @Override public String execute() throws Exception { if(!(user.getPassword().equals(user.getRePassword()))){ this.addFieldError("password", "请输入相同的密码"); return "input"; } else { HttpServletRequest request = ServletActionContext.getRequest (); request.setAttribute("user", user); return SUCCESS; } } public User getUser() { return user; } public void setUser(User user) { this.user = user; } } 博客分类 其它 目录