springmvc数据绑定出的错

在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写,

如果不一致,可能回报如下错误:

The request sent by the client was syntactically incorrect ().

从字面上理解是:客户端发送的请求语法错误。

实际就是springmvc无法实现数据绑定。 
查看一下你传的参数是不是有date类型等Springmvc不支持参数绑定的类型,需自己绑定

date时间类型绑定 String-->date

String--> date 时间格式

 1 package com.online.util;
 2
 3 import java.text.ParseException;
 4 import java.text.SimpleDateFormat;
 5 import java.util.Date;
 6 import java.util.Locale;
 7
 8 import org.springframework.format.Formatter;
 9
10 public class DateFormatter implements Formatter<Date>{
11
12
13     public String print(Date object, Locale locale) {
14         return null;
15     }
16
17     public Date parse(String text, Locale locale) throws ParseException {
18         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
19         Date date = null;
20         try {
21             date = format.parse(text);
22         } catch (Exception e) {
23             format = new SimpleDateFormat("yyyy-MM-dd");
24             date = format.parse(text);
25         }
26         return date;
27     }
28 }

在Spring的applicationContext.xml中注入这个类

1 <!-- 时间类型转换 -->
2     <bean id="conversionService"
3         class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
4         <property name="formatters">
5             <set>
6                 <bean class="com.online.util.DateFormatter"></bean>
7             </set>
8         </property>
9     </bean>  

在Springmvc.xml中使用 mvc:annotation-driven注解配置

1 <mvc:annotation-driven conversion-service="conversionService"/>

这样就是现了string-->date类型的转换

转载于:https://www.cnblogs.com/cmyxn/p/5895093.html

SpringMVC报错The request sent by the client was syntactically incorrect ()相关推荐

  1. Spring MVC报错:The request sent by the client was syntactically incorrect ()

    springmvc数据绑定是一个很好的东西,在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写,如果不一致,可能会报如下错误:  The ...

  2. The request sent by the client was syntactically incorrect. 错误以及spring事物

    mark一下: 1.   今天在做delete的时候不知道为什么hibernate一直就是不执行delete语句,查了好久没有查出来,最后想想是不是事物的问题,于是打开spring的配置文件看了看,哎 ...

  3. 错误400-The request sent by the client was syntactically incorrect

    前端接收服务器发送过来的实体类中含有日期类型或者后台是以对象的方式接收数据且对象中包含有日期类型 报错:错误400-The request sent by the client was syntact ...

  4. 又见The request sent by the client was syntactically incorrect ()

    前几天遇到过这个问题(Ref:http://www.cnblogs.com/xiandedanteng/p/4168609.html),问题在页面的组件name和和注解的@param名匹配不对,这个好 ...

  5. 错误The request sent by the client was syntactically incorrect ()的解决

    2019独角兽企业重金招聘Python工程师标准>>> 这个错误是SpringMVC报出来的,见到它意味着html/jsp页面的控件名称 和 controller里函数的参数不符. ...

  6. Spring MVC:The request sent by the client was syntactically incorrect

    一般是由于参数类型不正确所致.比如表单如下: <form:form action="" method="post" commandName="s ...

  7. java程序连接MinIO 报错The request signature we calculated does not match the signature you provided.

    java程序连接MinIO 报错The request signature we calculated does not match the signature you provided. Check ...

  8. VUE+Spring Boot,文件上传el-upload报错--Current request is not a multipart request,记录

    做了个简单的文件上传功能,测试时发现报错Current request is not a multipart request,网上查了很多办法,记录一下: 1.最多的:当前请求不是multipart ...

  9. kibana报错:Request must contain a kbn-xsrf header.

    kibana报错:Request must contain a kbn-xsrf header. 通过HTTP的DELETE 删除method,清除kibana的数据视图data_view时候 htt ...

最新文章

  1. 语言 全排列 函数_Power Query 中日期时间格式转换需要了解的区域语言对照表
  2. PaddleHub 口罩检测
  3. Spring Boot和Angular 2入门食谱
  4. [Leetcode][第696题][JAVA][计算二进制子串][分组]
  5. java 分治法排序_分治法实现1-N的数字按字典序全排列组合 Java语言
  6. Java多组输入实现 C++多组输入实现
  7. 安装laravel8
  8. android 锁屏代码分析,Android锁屏状态下的安全分析
  9. 成都拉升12名,长沙提升3位,最新全球城市排名出炉
  10. CENTOS上的时间/时区设定
  11. 双十一特辑:Python采集商品数据,实时了解商品价格
  12. eNSP第三篇:STP,生成树,xSTP,MSTP,多生成树,交换机工作原理,环路的形成
  13. 太阳表面的重力加速度
  14. C端和B端的差异分析
  15. ipython出现键盘输入错乱问题
  16. Python 实战系列-微信或网页远程控制电脑
  17. sitecore开发入门Sitecore的CRUD操作 - 第一部分
  18. 2023年5月产品经理认证NPDP线上班,我要报名学习
  19. 跨境电商一站式数字化管理ERP系统,帮你解决烦恼
  20. 数据传输完整性_制造系统数据完整性的特殊性(二)

热门文章

  1. IIS7批量FTP客户端工具软件
  2. EasyImage图床源码V2.0
  3. DT CMS致力于Spring Boot2.3.5 Vue前后端分离的RBAC权限框架(盛世美颜!)
  4. WordPress 主题教程 #6:侧边栏
  5. 响应式网页设计应该注意的9个原则
  6. 详解rel=”nofollow”的用法与意义
  7. shell循环,判断介绍,以及实例
  8. centos7/rhel7下安装redis4.0集群
  9. Linux——umask使用详解
  10. mysql MHA 集群搭建