spring登录注册不可以为空的简单实现

在entity的User的实现

public class User implements Serializable{
private int userId;
@NotEmpty(message="账号不能为空")
@Length(min=3,max=6,message="账号必须在3--6之间")
private String userName;
@NotEmpty(message="密码不能为空")
@Length(min=3,max=6,message="密码必须在3--6之间")
}

login.jsp:


<form:form action="loginHandler" method="post" commandName="user">
账号:<form:input path="userName"/><form:errors path="userName"/><br/>
密码:<form:password path="userPwd"/><form:errors path="userPwd"/><br/>
<input type="submit" value="提交"/>
</form:form>

猜你喜欢

转载自blog.csdn.net/qq_40036979/article/details/80101967