这个仁兄说得好……https://www.oschina.net/question/140550_20454
default message [Failed to convert property value of type 'Java.lang.String' to required type 'java.util.Date' for property 'sdate';
package com.lanyuan.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.core.convert.converter.Converter;
/**
* spring4 mvc 的日期传递[前台-后台]bug:
* 的解决方式.包括xml的配置
* new SimpleDateFormat("yyyy-MM-dd"); 或 new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
* 这里的日期格式必须与提交的日期格式一致
* @author lanyuan
* Email:mmm333zzz520@163.com
* date:2017-2-20
*/
public class SpringMVCDateConverter implements Converter<String, Date> {
@Override
public Date convert(String source) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setLenient(false);
try {
return dateFormat.parse(source);
} catch (Exception e) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
try {
return dateFormat.parse(source);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return null;
}
}
<mvc:annotation-driven conversion-service="conversionService" />
最后
以上就是顺心身影最近收集整理的关于webBindingInitializer 在XML中无效,spring mvc 3.2以版本的全部内容,更多相关webBindingInitializer内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复