Spring jsp 验证 form:errors标签
1 在model层添加验证规则
@NotNull
@Size(min=2,max =30,message="姓名在2-30个字符之间")
private String username;
2. 在model层添加验证规则
@PostMapping("/save")
public String save(@Valid User user, BindingResult result, RedirectAttributes redirectAttributes,Model model) { if(result.hasErrors()){
user.setXb("女");
model.addAttribute("user",user);
model.addAttribute("jinengItme",jineng());
model.addAttribute("guxiang",getGuxiang());
return "hello";
}
@Valid导入验证规则,BindingResult导入验证信息
result.hasErrors()遍历错误信息并输出
3.在视图层使用form:errors标签显示错误
<form:errors path="username" />
Spring jsp 验证 form:errors标签的更多相关文章
- Spring MVC中使用errors标签
先创建一个实体类,后续的验证都基于这个实体类: public class Goods { private String goodsName; private String city; private ...
- Spring MVC-表单(Form)标签-错误处理(Error Handling)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_errors.htm 说明:示例基于Spring MVC 4.1.6. 以下示例显 ...
- Spring MVC-表单(Form)标签-隐藏字段(Hidden Field)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_hidden.htm 说明:示例基于Spring MVC 4.1.6. 以下示例显 ...
- Spring MVC-表单(Form)标签-列表框(Listbox)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_listbox.htm 说明:示例基于Spring MVC 4.1.6. 以下示例 ...
- Spring MVC-表单(Form)标签-下拉框(Dropdown)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_dropdown.htm 说明:示例基于Spring MVC 4.1.6. 以下示 ...
- Spring MVC-表单(Form)标签-单选按钮集合(RadioButtons)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_radiobuttons.htm 说明:示例基于Spring MVC 4.1.6. ...
- Spring MVC-表单(Form)标签-单选按钮(RadioButton)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_radiobutton.htm 说明:示例基于Spring MVC 4.1.6. ...
- Spring MVC-表单(Form)标签-复选框集合(Checkboxes)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_checkboxes.htm 说明:示例基于Spring MVC 4.1.6. 以 ...
- Spring MVC-表单(Form)标签-复选框(Checkbox)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_checkbox.htm 说明:示例基于Spring MVC 4.1.6. 以下示 ...
随机推荐
- simcom7600ce-t LBS function
Welcome to minicom 2.7 OPTIONS: I18n Compiled on Nov 15 2018, 20:20:38.Port /dev/ttyUSB2, 00:55:23 P ...
- 好用的Google Chrome插件
juejin掘金 帮助我们随时了解Github上热门的项目,保证技术思想不掉队. Momentum 专注.待办清单…… Octotree Octotree 可以让我们在 Github 上浏览代码更加方 ...
- Angular2日期格式化
一:组件日期格式化: ts中调用: import {DatePipe} from "@angular/common"; @Component({ providers: [D ...
- java.lang.OutOfMemoryError:PermGen space tomcat7 内存溢出
Tomcat 解决 在启动项目的时候,会报java.lang.OutOfMemoryError:PermGen space错误. 在tomcat/bin/catalina.sh windows li ...
- 一个类中域(field)的首字母不要大写
首先这种写法不规范, 其次,至少在AJAX交互的情况下, 如果首字母大写,会无法与前端相同名称的JSON属性相绑定. 如 data:{'Name':'2017-10-19'} public NameI ...
- 线程池(2)-Executors提供4个线程池
1.为什么不使用Executors提供4个线程池创建线程池 阿里巴巴开放手册这样写: . [强制]线程池不允许使用 Executors 去创建,而是通过 ThreadPoolExecutor 的方式, ...
- ICEM-一种三维Y型网格
原视频下载地址:https://yunpan.cn/cLHD9ewat8v9a 访问密码 0f0f
- mysql安装和简要操作命令+python基本操作mysql数据库
mysql数据库是一种关系型数据库管理系统. 一. windows平台安装Mysql数据库. Mysql数据库官网 :https://dev.mysql.com/downloads/windows/ ...
- 关于JAVA线程池-ThreadPoolExecutor
1. 源码翻译 /* * * * * * * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Grou ...
- RK3288 查看ddr信息
转载请注明出处:https://www.cnblogs.com/lialong1st/p/10910949.html CPU:RK3288 系统:Android 5.1 1.查看ddr驱动版本号.容量 ...