Spring mvc时间格式处理
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时间格式处理的更多相关文章
- Spring中时间格式注解@DateTimeFormat
在SpringMVC中Controller中方法参数为Date类型想要限定请求传入时间格式时,可以通过@DateTimeFormat来指定,但请求传入参数与指定格式不符时,会返回400错误. 如果在B ...
- Spring MVC 时间字符串 @PathVariable获取
@PathVariable("date") @DateTimeFormat(pattern="yyyy-MM-dd") Date date
- Spring mvc 时间转换
http://www.cnblogs.com/ssslinppp/p/4600043.html
- 彻底解决Spring mvc中时间的转换和序列化等问题
痛点 在使用Spring mvc 进行开发时我们经常遇到前端传来的某种格式的时间字符串无法用java8的新特性java.time包下的具体类型参数来直接接收. 我们使用含有java.time封装类型的 ...
- 彻底解决Spring mvc中时间类型的转换和序列化问题
在使用Spring mvc 进行开发时我们经常遇到前端传来的某种格式的时间字符串无法用java8时间包下的具体类型参数来直接接收.同时还有一系列的序列化 .反序列化问题,在返回前端带时间类型的同样会出 ...
- Spring MVC请求执行流程
学习Spring MVC时间有点长了,但是最近打算找工作,需要重新了解下,所以又去温故知新了.Spring MVC就是用来写web的框架,简化你写web的一些不必要的流程,让程序员能专注于业务逻辑也就 ...
- Spring MVC中的HandlerMapping与HandlerAdapter
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- Abp 修改默认的日期时间格式
abp默认是不使用mvc的时间格式,所以直接在AddMvc修改DateFormatString是不会生效的.需要先启用mvc时间格式.Configuration.Modules.AbpAspNetCo ...
- 【,NetCore】WebApi使用统一时间格式
1.在Startup中配置统一时间格式 services.AddMvc() .AddJsonOptions(options => { //配置时间序列化格式 options.Serializer ...
随机推荐
- 数据库中char与varchar类型的区别
在建立数据库表结构的时候,为了给一个String类型的数据定义一个数据库的数据库类型,一般参考的都是char或者varchar,这两种选择有时候让人很纠结,今天想总结一下它们两者的区别,明确一下选择塔 ...
- dataTables获取当前行json格式数据
装载表格数据 $(document).ready( function () { //页面加载后装载表格数据 var table = $('#mytable').DataTable( { "s ...
- Java加载资源文件几种方法
from: http://andyzhu.blog.51cto.com/4386758/775836/ import java.net.URL; import org.springframework. ...
- PHP 自动加载规范PSR-4
.note-content { font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeit ...
- iframe用js设定自定义高度
JS代码 function SetWinHeight(obj){ var win=obj; if (document.getElementById){ if (win && !wind ...
- BZOJ1492: [NOI2007]货币兑换Cash
设$x_j$,$y_j$为第$j$天能买的A,B券数量,$f_i$为第$i$天的最大收益.$f_i=\max_{1\le j<i}a_ix_j+b_iy_j$,最大化$f_i$即找一个点$(x_ ...
- 一道javascript数组操作题
题目如下: var arr = ['100px','abc'-6,[],-98765,34,-2,0,'300',,function(){alert(1);}, null, document, [], ...
- js正则表达式(1)
定义正则: var reg = new RegExp('a'); //实例化对象,参数是我们想要制定的规var reg = /a/; //简写方法 正则的常用方法: 1.test():在字符串中查找符 ...
- webapi returntype
- iOS 组件化方案探索
来自bang's blog http://blog.cnbang.net/tech/3080/