首先,在pom.xml中添加hibernate.validator的支持
[html] view plaincopy
<!-- hibernate.validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.1.Final</version>
</dependency>
表单提交页面user_add.jsp
[html] view plaincopy
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>add user</title>
</head>
<body>
<form:form id="form" method="post"
modelAttribute="validUserBean">
添加用户
<form:label path="account">账号:</form:label>
<form:input path="account" />
<form:errors path="account" />
<form:label path="password">密码:</form:label>
<form:input path="password" />
<form:errors path="password" />
<button type="submit">添加</button>
<button type="reset">重置</button>
<c:out value="${show}"></c:out>
</form:form>
</body>
</html>
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....