在entity的User的实现
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>