SPRING IN ACTION 第4版笔记-第五章BUILDING SPRING WEB APPLICATIONS-007-表单验证@Valid、Error
2024-08-27 04:47:58
一、
Starting with Spring 3.0, Spring supports the Java Validation API in Spring MVC . No extra configuration is required to make Java Validation work in Spring MVC . You just need to make sure an implementation of the Java API , such as Hibernate Validator, is in the project’s classpath.
1.
2.在实体类写约束
public class Spitter { private Long id; @NotNull
@Size(min=5, max=16)
private String username; @NotNull
@Size(min=5, max=25)
private String password; @NotNull
@Size(min=2, max=30)
private String firstName; @NotNull
@Size(min=2, max=30)
private String lastName; @NotNull
private String email;
3.controller中
@RequestMapping(value="/register", method=POST)
public String processRegistration(
@Valid Spitter spitter,
Errors errors) {
if (errors.hasErrors()) {
return "registerForm";
}
最新文章
- git使用
- Android自定义Dialog及其布局
- IOS基础之 (四) OC对象
- CS程序,服务器端弹出MessageBox.Show()之类的UI操作???禁止
- java中的线程创建和使用
- cocos2d-x 3.0正式版 环境搭建 (解决载入失败,未能载入XXX包)
- 制作Net程序的帮助文档--总结
- 折腾Python中的Tkinter
- MySQL索引创建、删除、查看
- 解决设置clickablespan后长按冲突的问题
- 移动端click事件300ms延迟
- ArcGIS 中UniqueValueRenderer和SimpleRenderer的异同点
- 微信小程序- 提示不在以下合法域名列表中
- sqlserver window身份验证时切换账户的快捷键
- Docker在Windows下的安装以及Hello World
- C# XML对象序列化、反序列化
- 十个jQuery图片画廊插件推荐
- 打开当前目录的其他exe
- Ubuntu14.04(64位)下gcc-linaro-arm-linux-gnueabihf交叉编译环境搭建
- Leader Election
热门文章
- Agile.Net 组件式开发平台 - 开发环境部署
- 反汇编windows htonl()函数
- Could not find artifact com.sun:tools:jar:1.5.0解决方法
- 从V$SQL_PLAN中FORMAT执行计划
- 第十二篇、HTML常用框架收集
- From MSI to WiX, Part 2 - ARP support, by Alex Shevchuk
- Qt-获取网络接口信息的综合示例
- Cloudcraft: 云架构图形可视化(智能AWS图表)
- PHP 类和继承
- NUnit单元测试