【SpringMVC】使用@InitBind来解决字符串转日期类型(十三)
来源:互联网 发布:淘宝ppr外丝活接 编辑:程序博客网 时间:2024/06/05 11:18
1) 在默认情况下,springmvc不能将String类型转成java.util.Date类型,所有我们只能在Action
中自定义类型转换器
<form action="${pageContext.request.contextPath}/user/add.action" method="POST">编号:<input type="text" name="id" value="${id}"/><br/>姓名:<input type="text" name="name" value="${name}"/><br/>薪水:<input type="text" name="sal" value="${sal}"/><br/>入职时间:<input type="text" name="hiredate" value='<fmt:formatDate value="${hiredate}" type="date"/>'/><br/><input type="submit" value="注册"/></form>
@Controller@RequestMapping(value = "/user")public class UserAction {@InitBinderprotected void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {binder.registerCustomEditor(Date.class,new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));}@RequestMapping(value = "/add", method = RequestMethod.POST)public String add(int id, String name, double sal, Date hiredate,Model model) throws Exception {System.out.println("HelloAction::add()::POST");model.addAttribute("id", id);model.addAttribute("name", name);model.addAttribute("sal", sal);model.addAttribute("hiredate", hiredate);return "/register.jsp";}}
阅读全文
0 0
- 【SpringMVC】使用@InitBind来解决字符串转日期类型(十三)
- 使用@InitBind来解决字符串转日期类型 (9)
- SpringMVC 在业务控制方法中写入模型变量收集参数,且使用@InitBind来解决字符串转日期类型
- springmvc框架中,在业务控制方法中写入模型变量收集参数,且使用@InitBind来解决字符串转日期类型
- 解决springmvc日期类型序列化
- 解决springMVC无法接受日期类型参数
- Springmvc接收前台字符串类型日期格式转换
- 字符串转日期时间类型
- MySQL字符串转日期类型
- jquery字符串转日期类型
- 日期类型和字符串类型互转
- springmvc(十三)springmvc注解开发-springmvc参数绑定-包装类型pojo参数绑定
- flex4 日期类型字符串转日期类型(string转Date)
- flex4 日期类型字符串转日期类型(string转Date)
- Flex4 日期类型字符串转日期类型(string转Date)
- Flex4 日期类型字符串转日期类型(string转Date)
- flex4 日期类型字符串转日期类型(string转Date)
- (转)SpringMVC:提交数据遭遇基础类型和日期类型报400错误解决方法
- 测试投入度量元的选择
- nipype处理核磁数据(二)——FSL、FreeSurfer的安装
- 400人秘密在此研发Alexa 走进亚马逊剑桥研发中心
- C#读取csv文件
- 使用ioctl获取磁盘大小
- 【SpringMVC】使用@InitBind来解决字符串转日期类型(十三)
- 《剑指offer》刷题笔记(时间效率):数组中出现次数超过一半的数字
- vue2引入外部js文件(以hammer.js为例)
- Android数据库两种操作方式介绍: SQLite与ORMLite
- disable_irq与disable_irq_nosync
- MYSQL 插入性能优化
- WEB前端 -- 块元素与内联元素
- 数据输出
- 人机对话这件事为什么难?| 清华x-lab人工智能研习社