springmvc数据绑定出的错

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

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

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

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

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

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

String--> date 时间格式

 package com.online.util;

 import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale; import org.springframework.format.Formatter; public class DateFormatter implements Formatter<Date>{ public String print(Date object, Locale locale) {
return null;
} public Date parse(String text, Locale locale) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(text);
} catch (Exception e) {
format = new SimpleDateFormat("yyyy-MM-dd");
date = format.parse(text);
}
return date;
}
}

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

 <!-- 时间类型转换 -->
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="formatters">
<set>
<bean class="com.online.util.DateFormatter"></bean>
</set>
</property>
</bean>

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

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

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

SpringMVC报错The request sent by the client was syntactically incorrect ()的更多相关文章

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

    原因: 1.参数名称不一致 2.参数类型不一致

  2. spring mvc 在上传图片时,浏览器报The request sent by the client was syntactically incorrect

    项目中,在一个jsp页面里其它图片上传是功能是可以使用的,当我自己新加了一个图片上传时,提交表单后,浏览器报The request sent by the client was syntactical ...

  3. 错误:The request sent by the client was syntactically incorrect的解决

    问题: 错误400-The request sent by the client was syntactically incorrect. springMVC中,某个页面提交时报400错误,如下图. ...

  4. SpringMVC---400错误The request sent by the client was syntactically incorrect ()

    在SpringMVC中使用@RequestBody和@ModelAttribute注解时遇到了很多问题,现记录下来. @ModelAttribute这个注解主要是将客户端请求的参数绑定参数到一个对象上 ...

  5. The request sent by the client was syntactically incorrect.

    HTTP Status 400 - type Status report message description The request sent by the client was syntacti ...

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

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

  7. "The request sent by the client was syntactically incorrect ()"问题定位及解决:

    Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法: 把spring日志级 ...

  8. The request sent by the client was syntactically incorrect问题解决

    The request sent by the client was syntactically incorrect意思嘛,google翻译一下 通过日志不难看出,是由参数不匹配造成的. 所以对于Da ...

  9. HTTP Status 400 - description The request sent by the client was syntactically incorrect.

    HTTP Status 400 - type Status report message description The request sent by the client was syntacti ...

随机推荐

  1. zepto源码--核心方法2(class相关)--学习笔记

    继续上篇,本片主要介绍的是$.fn中与class相关的函数,包括hasClass, addClass, removeClass, toggleClass hasClass: 检查对象集合中是否有元素含 ...

  2. Javascript模块化编程(三):require.js的用法 作者: 阮一峰

    声明:转载自阮一峰的网络日志 这个系列的第一部分和第二部分,介绍了Javascript模块原型和理论概念,今天介绍如何将它们用于实战. 我采用的是一个非常流行的库require.js. 一.为什么要用 ...

  3. jenkins创建job不能用中文问题

    Your Container doesn't use UTF-8 to decode URLs. If you use non-ASCII characters as a job name etc,  ...

  4. HTML两张图片叠加问题的进一步修改

    要想两张图片叠加,只需在circle添加一个Position:absolute就OK了 以上几步,很多大侠前辈都已经说过,相信不用再啰嗦,我想说的是一种扩展,将示例放到右边,可能因为我悟性低,研究了一 ...

  5. Mysql乱码

    MySql字符集 1.系统默认的.数据库默认的.表格默认的.列的 真正决定权在列定义上 2.latin1 系统默认字符编码 字符范围是0x00-0xff,可以存放任意编码的字符序列. 3.utf8编码 ...

  6. URL后面带\斜杠对SEO的影响

    例如以下的两种URL书写方式: 1.www.baidu.com 2.www.baidu.com\ 这两种书写方式的区别到底在哪里呢?哪一个的速度更快呢?可能对于我们大多数人来说会觉得两个速度一样,因为 ...

  7. android opengl

    引用:http://weimingtom.iteye.com/blog/1616972 二维坐标系变换为原点在左上角(测试用) * GLES * JOGL * LWJGL * libgdx(使用g2d ...

  8. nodejs框架express快速开始

    认识express 创建应用 get请求 简述中间件 all方法 use方法1 use方法2 回调函数 获取主机.路径名 Get请求 - query Get请求 - param Get请求 - par ...

  9. Bison

  10. Django开发笔记之数据库的设计

    后台采用Django开发,可以体会到开发的便利之处,对于一个项目来说,首先最重要的是数据库的设计,那么在Django下数据库设计主要是如下步骤: 1,需求分析,这点子不用多说,而我也深刻体会到了没有原 ...