spring mvc中,如果时间格式是yyyy-MM-dd,传入后台会报错,要增加一些配置才可以。

1.修改spring-mvc.xml,增加org.springframework.format.support.DefaultFormattingConversionService

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingFastJsonHttpMessageConverter"/> <!-- JSON转换器 -->
</list>
</property>
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conService" />
</bean>
</property>
</bean> <bean id="conService" class="org.springframework.format.support.DefaultFormattingConversionService"/>

2.在实体属性处增加DateTimeFormat注解

 @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date reqisterDate;

Spring mvc时间格式处理的更多相关文章

  1. Spring中时间格式注解@DateTimeFormat

    在SpringMVC中Controller中方法参数为Date类型想要限定请求传入时间格式时,可以通过@DateTimeFormat来指定,但请求传入参数与指定格式不符时,会返回400错误. 如果在B ...

  2. Spring MVC 时间字符串 @PathVariable获取

    @PathVariable("date") @DateTimeFormat(pattern="yyyy-MM-dd") Date date

  3. Spring mvc 时间转换

    http://www.cnblogs.com/ssslinppp/p/4600043.html

  4. 彻底解决Spring mvc中时间的转换和序列化等问题

    痛点 在使用Spring mvc 进行开发时我们经常遇到前端传来的某种格式的时间字符串无法用java8的新特性java.time包下的具体类型参数来直接接收. 我们使用含有java.time封装类型的 ...

  5. 彻底解决Spring mvc中时间类型的转换和序列化问题

    在使用Spring mvc 进行开发时我们经常遇到前端传来的某种格式的时间字符串无法用java8时间包下的具体类型参数来直接接收.同时还有一系列的序列化 .反序列化问题,在返回前端带时间类型的同样会出 ...

  6. Spring MVC请求执行流程

    学习Spring MVC时间有点长了,但是最近打算找工作,需要重新了解下,所以又去温故知新了.Spring MVC就是用来写web的框架,简化你写web的一些不必要的流程,让程序员能专注于业务逻辑也就 ...

  7. Spring MVC中的HandlerMapping与HandlerAdapter

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  8. Abp 修改默认的日期时间格式

    abp默认是不使用mvc的时间格式,所以直接在AddMvc修改DateFormatString是不会生效的.需要先启用mvc时间格式.Configuration.Modules.AbpAspNetCo ...

  9. 【,NetCore】WebApi使用统一时间格式

    1.在Startup中配置统一时间格式 services.AddMvc() .AddJsonOptions(options => { //配置时间序列化格式 options.Serializer ...

随机推荐

  1. Java学习笔记(二)

    再次更新,有问题大家一起讨论 Java中的class文件转换成.java文件 下载转换器Java Decompiler 使用此转换器打开.jar文件 就可以看到由.class转换来的.java文件 亲 ...

  2. Scala - 隐式转换和隐式参数

    隐士转换是Scala提供的一种语法糖 Implicit definitions are those that the compiler is allowed to insert into a prog ...

  3. NOIP2016滚粗记

    想了好久还是决定要写... Day0 Day-5得感冒一直没好,连磕5天药丸. 早晨得知爸妈都要上班并不能送我到校的消息,于是计划10:30集合,定表8:45准备自己走去学校. 然后平常睡得有点晚,结 ...

  4. MySQL、MongoDB、Redis数据库Docker镜像制作

    MySQL.MongoDB.Redis数据库Docker镜像制作 在多台主机上进行数据库部署时,如果使用传统的MySQL的交互式的安装方式将会重复很多遍.如果做成镜像,那么我们只需要make once ...

  5. php截取中文无乱码

    在PHP中需要对字符串进行截取,如果没有装mb扩展(mb_substr函数),对中文截取就需要进行相应的处理.下面是对字符串 "世s界s的功s\\\夫萨的mn是非得失sdf dsf dsf ...

  6. POJ 2251 Dungeon Master(3D迷宫 bfs)

    传送门 Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28416   Accepted: 11 ...

  7. ui library

    https://github.com/twbs/bootstrap https://github.com/semantic-org/semantic-ui/ https://github.com/zu ...

  8. JSPatch 技术要点

    作者:干掉crash链接:https://zhuanlan.zhihu.com/p/21884786来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 如果有方法不遵守语言 ...

  9. SQL Server存储过程创建和修改

    create proc Get_Data( @Del_ID varchar(36))asselect * from Depts where DeptId=@Del_ID select * from D ...

  10. 二维码相关---java生成二维码名片,并且自动保存到手机通讯录中...

    http://blog.csdn.net/lidew521/article/details/24441825