在其他对象属性类型一样情况下,只需要创建一个类,再在springmvc.xml中添加配置:

  1. package com.ujiuye.common;
  2.  
  3. import org.springframework.core.convert.converter.Converter;
  4.  
  5. import java.text.SimpleDateFormat;
  6. import java.util.Date;
  7.  
  8. public class DateTimeConverter implements Converter<String, Date> {
  9. public Date convert(String s) {
  10. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  11. try{
  12. Date date = sdf.parse(s);
  13. return date;
  14. }catch (Exception ex){
  15. System.out.println(ex.getMessage());
  16. return null;
  17. }
  18. }
  19. }
  1. <!--全局类型转型器-->
  2. <bean id="converter" class="com.ujiuye.common.DateTimeConverter"></bean>
  3. <bean id="formattingConversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
  4. <property name="converters">
  5. <set>
  6. <ref bean="converter"></ref>
  7. </set>
  8. </property>
  9. </bean>
  10. <mvc:annotation-driven conversion-service="formattingConversionService"/>
  11.  
  12. <mvc:annotation-driven/>

SpringMVC中的400错误,The request sent by the client was syntactically incorrect.的更多相关文章

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

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

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

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

    springMVC中,某个页面提交时报400错误,如下图.     解决方法: 1.在网上找了一下,答案是通常遇到这个错误是因为前端jsp页面的控件名称和controller中接收的参数名称不一致.但 ...

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

    http://www.cnblogs.com/xiandedanteng/p/4168609.html 这个错误是SpringMVC报出来的,见到它意味着html/jsp页面的控件名称 和 contr ...

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

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

  6. SpringMVC报错The request sent by the client was syntactically incorrect ()

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

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

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

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

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

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

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

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

随机推荐

  1. Elasticsearch 报错:Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_field_name`] in order to load fielddata in memory by uninverting the inverted index.

    Elasticsearch 报错: Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_fi ...

  2. Linux下使用cx_Oracle的一些配置

    在安装完成cx_Oracle后,import  cx_Oracle时报错,首先查看.bash_profile文件中环境变量配置 # .bash_profile # Get the aliases an ...

  3. socket套接字及粘包问题

    socket套接字 1.什么是socket socket是一个模块,又称套接字,用来封装互联网协议(应用层以下的层) 2.为什么要有socket 实现应用层以下的层的工作,提高开发效率 3.怎么使用s ...

  4. hbase表的高性能设计

    第7章 HBase优化 7.1 高可用 在HBase中Hmaster负责监控RegionServer的生命周期,均衡RegionServer的负载,如果Hmaster挂掉了,那么整个HBase集群将陷 ...

  5. 防御流类型的xss攻击

    1.建立一个工具类 package im.lsn.oss.exhibition.utils; import org.apache.commons.lang3.StringUtils; import j ...

  6. LeetCode 825. Friends Of Appropriate Ages

    原题链接在这里:https://leetcode.com/problems/friends-of-appropriate-ages/ 题目: Some people will make friend ...

  7. 说几条JavaScript的基本规范

    1.不要在同一行声明多个变量 2.使用===或!==来比较 3.使用字面量的方式来创建对象.数组,替代new Array这种形式 4.不要使用全局函数 5.switch语句必须要带default分支 ...

  8. Flask视图之CBV示列

    from flask import views, Flask app=Flask(__name__) class loginview( views.MethodView ):   # 继承views. ...

  9. 使用golang写一个redis-cli

    使用golang写一个redis-cli 0. redis通信协议 redis的客户端(redis-cli)和服务端(redis-server)的通信是建立在tcp连接之上, 两者之间数据传输的编码解 ...

  10. c++功能与方法笔记

    1. windows判断创建目录 #include <Shlwapi.h> #pragma comment(lib, "shlwapi.lib") //windows ...