如题,代码简单介绍如下:
public class MyBindingInitializer implements WebBindingInitializer { @Override
public void initBinder(WebDataBinder binder, WebRequest request) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                dateFormat.setLenient(false);
                binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}}mvc中该部分配置文件
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="com.xx.xx.MyBindingInitializer"/>
</property>
</bean>
设置了这个然后启动服务器,结果运行的时候绑定Date类型属性的时候无效,如果在Controller类中用@InitBinder方法注解实现却可以,请问是什么情况?
说明下:网上找到的修改配置文件位置 “把<mvc:annotation-driven/>放到下面就可以了”,此方法试过无效
运行环境:spring3.0.3 + tomcat 6.0.30