Failed to convert value of type 'java.lang.String' to required type 'java.util.Date
异常原因:Controller层获取JSP页面请求参数是String类型,而在Controller层接收时使用Date类型,属于方法参数类型不匹配异常
警告: Failed to bind request element: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2019-06-18'; nested exception is java.lang.IllegalArgumentException
错误代码
@RequestMapping("/test2")public void test2( String name, int age, Date birth){System.out.println(name);System.out.println(age);System.out.println(birth);}
解决办法:Date类型前加注解:@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
@RequestMapping("/test2")public void test2( String name, int age,@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date birth){System.out.println(name);System.out.println(age);System.out.println(birth);}
Failed to convert value of type 'java.lang.String' to required type 'java.util.Date相关推荐
- Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro
Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro ...
- spring:Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘
前言 springboot有接口日期转换的经典问题,给Entity加@JsonFormat解决了输出json日期格式的输入输出问题,但是解决不了非@RequestBody/也就是普通表单提交的日期格式 ...
- Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
在Java的controller中添加一个方法即可解决 /*** 解决:Failed to convert value of type 'java.lang.String' to required t ...
- Cannot convert value of type ‘java.lang.String‘ to required type ‘java.util.Map‘ for property ‘param
问题描述 若依中使用feign进行远程调用,在get请求中使用@SpringQueryMap映射对象时,映射对象的父类中带有Map<String, Object>类型的params属性时, ...
- 报错: Cannot convert value of type ‘java.lang.String‘ to required type
报错: Cannot convert value of type 'java.lang.String' to required type Caused by: java.lang.IllegalSta ...
- 配置文件报错 Cannot convert value of type ‘java.lang.String‘ to required type ‘javax.sql.DataSource‘ for p
问题 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean&qu ...
- Filed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘ for XX
添加注解: @DateTimeFormat:前端传值到后台接收准确的Date类属性 @JsonFormat:数据库到实体类的Date类型转换 @JsonFormat(pattern = "y ...
- Spring Boot 集成Kafka java.lang.String is in module java.base of loader ‘bootstrap‘;
异常信息:java.lang.String is in module java.base of loader 'bootstrap'; com.htcyaifline.common.kafka.dom ...
- Unable to make field private final byte[] java.lang.String.value accessible: module java.base does n
问题: Unable to make field private final java.lang.String java.io.File.path accessible: module java.ba ...
最新文章
- 推荐系统-03-简单基于用户的推荐
- sql语句查询性能的优化思想(个人理解)
- Django 连接Mysql异常处理
- HDU ACM 1267 下沙的沙子有几粒?-gt;DP
- 右键助手1.0正式版
- 有关架构图你需要了解的基础知识
- IGNN图卷积超分网络:挖掘隐藏在低分辨率图像中的高清纹理
- 四六级考试中的计算机类文章,毕业设计论文-基于web的英语四六级模拟在线考试系统.doc...
- PostgreSQL GPU 加速(HeteroDB pg_strom) (GPU计算, GPU-DIO-Nvme SSD, 列存, GPU内存缓存)
- Struts2框架中s:if标签和s:set标签小结
- linux内核奇遇记之md源代码解读之七阵列同步一
- java - 小程序二维码中间的logo占整个二维码的比例计算
- 苹果手机自带表格软件_苹果手机还自带扫描仪,没想到今天才发现
- 远程如何重装linux系统,独立服务器远程重装Linux系统
- 互联网公司招聘--人人网--产品岗-2015年笔试题
- Linux常用命令、相关软件安装及项目部署
- 支持Apple Music无损音频的耳机型号以及iPhone、iPad
- 有感而发20210216
- Halcon联合VS2010打开相机并显示
- 介绍Python/Django的在线好书推荐