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. Jquery中的队列函数quene()、dequene()、clearQuene()

    jQuery中的queue和dequeue是一组很有用的方法,他们对于一系列需要按次序运行的函数特别有用.特别animate动画,ajax,以及timeout等需要一定时间的函数.Queue()和de ...

  2. libgdx actor 透明问题

    遇到一个问题,自定义的Actor在使用batch.draw时,其他Actor设置的透明影响到了这个Actor 处理方法为 在自定义Actor中 draw方法中 绘制前,加入 Color color = ...

  3. 学习quartz定时

    学习资料: http://www.cnblogs.com/Rozdy/p/4274356.html http://www.cnblogs.com/Rozdy/p/4284339.html https: ...

  4. Centos7网络配置,vsftpd安装及530报错解决

    今天在虚拟机安装CentOS7,准备全新安装LTMP,结果又是一堆问题,不过正好因为这些出错,又给自己长了见识. 1,CentOS7网络配置 最小化安装CentOs7后,ifconfig提示comma ...

  5. Unity中那些事半功倍的好插件

    Unity开发最好的地方就是有各种强大的插件,有哪些插件让大家事半功倍,稳定强大 值得推荐学习和入手呢?Unity5.0之后,制作UI 以及UI的动画,UI特效,大家一般都使用什么插件?或者说有什么好 ...

  6. Android--Retrofit+RxJava(二)

    1,现在响应式编程也是越来越多在项目中使用了,刚好上篇我们简单了介绍了一下Retrofit,那么我们来开始试着两个一起用吧,不过不了解RxJava的同学可以先去看一看这个文章(挺好的):http:// ...

  7. webApp 开发技术要点总结

    如果你是一名前端er,又想在移动设备上开发出自己的应用,那怎么实现呢?幸好,webkit内核的浏览器能帮助我们完成这一切.接触 webkit webapp的开发已经有一段时间了,现把一些技巧分享给大家 ...

  8. 关于学习Knockoutjs--入门(一)

    前段时间做项目一直在用knockout,虽然用着不怎么利索,但是知识是一点一点探索的. 首先介绍一下 Knockout是什么? 他是一个很优秀的js库,他最大的功能就是实现双向绑定,它可以帮助你仅使用 ...

  9. MVC(二)

    所谓EF延迟加载,就是使用Lamabda或Linq查询数据时,EF并不会将数据直接查询出来,而是在用到的这个查询结果的时候才会加载到内存中.延迟加载也可以理解成 按需加载,顾名思义,就是按照所需的数据 ...

  10. JavaScript原型理解

    这东西我还不是很理解,但是把自己实践的过程记录下来,希望积累到一定程度,能自然而而然的理解了.很多东西我是这样慢慢理解的,明白为啥是那样子,真的很神奇哦.少说废话,开始吧. 可以先阅读这篇文章 fun ...