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. 使用Eclipse进行远程调试

    转自:http://blog.csdn.net/sunyujia/article/details/2614614 今天决定做件有意义的事,写篇图文并茂的blog,为什么要图文并茂?因为很多事可能用语言 ...

  2. python3 @classmethod 的使用场合

    官方的说法: classmethod(function)中文说明:classmethod是用来指定一个类的方法为类方法,没有此参数指定的类的方法为实例方法,使用方法如下: class C: @clas ...

  3. 关于我-dinphy简介

    别   名:孜_行 英文名:dinphy QQ交流群:588266650 兴趣爱好:听音乐.打篮球.热衷于诗词文学 专    业:计算机 了    解:windows及Linux.android的基本 ...

  4. Javascript JQuery获取当前元素的兄弟元素/上一个/下一个元素(转)

    var chils= s.childNodes; //得到s的全部子节点 var par=s.parentNode; //得到s的父节点 var ns=s.nextSbiling; //获得s的下一个 ...

  5. Android源码——AsynTask

    AsyncTask<Params, Progress, Result>中三个参数为: Params         输入数据 Progress       过程数据 Result     ...

  6. Angularjs兼容IE

    http://www.tuicool.com/articles/EJv6riY http://www.angularjs.cn/A00v http://www.cnblogs.com/ahl5esof ...

  7. 在UP Board 上搭建M——L服务器

    前言 原创文章,转载引用务必注明链接,水平有限,欢迎指正. 本文环境:ubilinux 3.0 on UP Board 初识免流 所谓免流,就是免除手机访问网络产生的流量费用.其原理在乌云网上有过报道 ...

  8. pdf在线处理网站

    https://smallpdf.com/unlock-pdf

  9. This month Calendar

    package fourth;import java.text.DateFormatSymbols;import java.util.*;public class CalendarTest { pub ...

  10. System.Web.Http.Cors配置跨域访问的两种方式

    System.Web.Http.Cors配置跨域访问的两种方式 使用System.Web.Http.Cors配置跨域访问,众多大神已经发布了很多文章,我就不在详细描述了,作为小白我只说一下自己的使用心 ...