日期:2014-05-20 浏览次数:20812 次
<body> <s:fielderror></s:fielderror> <s:form action="loginAction" namespace="/login" method="post" name="loginform"> <s:textfield name="vo.username"></s:textfield> <br /> <s:password name="vo.password"></s:password> <br /> <s:submit value="登陆"></s:submit> </s:form> </body>
public void validate() { String username = vo.getUsername(); String password = vo.getPassword(); [color=#FF0000]System.out.println(username);[/color]//第二次提交时能接收到数据,可还是返回了input [color=#FF0000]System.out.println(password);[/color] if(username==null || username.trim().length()==0) { this.addFieldError("vo.username", "用户名不能为空"); } if(password==null || password.trim().length()==0) { this.addFieldError("vo.password", "密码不能为空"); } }