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类型的转换

最新文章

  1. Android Studio中获取SHA1或MD5的方法
  2. sqldeveloper
  3. linux 解压xz包
  4. BZOJ 3670 &amp;&amp; BZOJ 3620 &amp;&amp; BZOJ 3942 KMP
  5. 无线电源传输 Wireless Power Consortium (WPC) Communication
  6. Tor
  7. 20145317彭垚 《Java程序设计》第7周学习总结
  8. python中关于正则表达式
  9. createdb test时报global/pg_filenode.map不存在
  10. C++指针的引用
  11. 简谈HTML5与APP技术应用
  12. 使用Filter防止浏览器缓存页面或请求结果
  13. [RxJS] What RxJS operators are
  14. 查看SQLServer数据库信息的SQL语句
  15. 学习ExpressionTree(做装配脑袋出的练习题)
  16. java代理的深入浅出(二)-CGLIB
  17. python web框架之Tornado
  18. mybatis 开发规范
  19. SQL笔记之SELECT语句
  20. “指定的参数已超出有效值的范围”在【 parameterUpdate.Add(new OracleParameter(&quot;STATUS&quot;, 0));】报错

热门文章

  1. nodejs 80端口监听失败及NODE_PATH不起作用的问题
  2. ubifs物理存储
  3. Python之路-python(面向对象一)
  4. HTML 中按钮作为form表单元素提交特性两则 --- 参HTML考标准分析
  5. http协议 301和302的原理及实现
  6. CPlus的简单线程的制作
  7. iOS开发中NSLog输出格式大全
  8. yield return的作用
  9. vm虚拟机启动失败 Global\vmx86
  10. Centos7下Rinetd安装与应用