异常原因: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相关推荐

  1. 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 ...

  2. spring:Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘

    前言 springboot有接口日期转换的经典问题,给Entity加@JsonFormat解决了输出json日期格式的输入输出问题,但是解决不了非@RequestBody/也就是普通表单提交的日期格式 ...

  3. 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 ...

  4. Cannot convert value of type ‘java.lang.String‘ to required type ‘java.util.Map‘ for property ‘param

    问题描述 若依中使用feign进行远程调用,在get请求中使用@SpringQueryMap映射对象时,映射对象的父类中带有Map<String, Object>类型的params属性时, ...

  5. 报错: 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 ...

  6. 配置文件报错 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

最新文章

  1. 推荐系统-03-简单基于用户的推荐
  2. sql语句查询性能的优化思想(个人理解)
  3. Django 连接Mysql异常处理
  4. HDU ACM 1267 下沙的沙子有几粒?-gt;DP
  5. 右键助手1.0正式版
  6. 有关架构图你需要了解的基础知识
  7. IGNN图卷积超分网络:挖掘隐藏在低分辨率图像中的高清纹理
  8. 四六级考试中的计算机类文章,毕业设计论文-基于web的英语四六级模拟在线考试系统.doc...
  9. PostgreSQL GPU 加速(HeteroDB pg_strom) (GPU计算, GPU-DIO-Nvme SSD, 列存, GPU内存缓存)
  10. Struts2框架中s:if标签和s:set标签小结
  11. linux内核奇遇记之md源代码解读之七阵列同步一
  12. java - 小程序二维码中间的logo占整个二维码的比例计算
  13. 苹果手机自带表格软件_苹果手机还自带扫描仪,没想到今天才发现
  14. 远程如何重装linux系统,独立服务器远程重装Linux系统
  15. 互联网公司招聘--人人网--产品岗-2015年笔试题
  16. Linux常用命令、相关软件安装及项目部署
  17. 支持Apple Music无损音频的耳机型号以及iPhone、iPad
  18. 有感而发20210216
  19. Halcon联合VS2010打开相机并显示
  20. 介绍Python/Django的在线好书推荐

热门文章

  1. 《Java修炼指南:高频源码解析》阅读笔记一Java数据结构的实现集合类
  2. 微信公众号的纯文本链接设置
  3. Python OpenCV 图片滑块验证码自动识别方案分析与自动化识别方案实现 图片相似度对比 OpenCV如何找到图片中的正方形并进行标记?
  4. 帷幕的帷是什么意思_人为什么要结婚?看看情感大师是怎么说的
  5. 软件生命周期-SDLC-的六个阶段简单介绍
  6. Echarts树形结构图加点击事件
  7. yapi 全局变量使用_需要接口管理的你了解一下?
  8. 火狐开发----Web开发者工具
  9. 微服务架构通讯模式架构分析
  10. (四)拒绝服务–TearDrop 攻击