zoukankan      html  css  js  c++  java
  • WebBindingInitializer学习

    今天在看开源代码的时候遇到了这个接口,于是查阅了下相关的资料

    Spring web mvc学习笔记

    http://www.cnblogs.com/crazy-fox/archive/2012/02/18/2357699.html

    WebBindingInitializer 接口来实现全局注册 使用@InitBinder只能对特定的controller类生效,为注册一个全局的customer Editor,可以实现接口WebBindingInitializer 。

    复制代码
    public class CustomerBinding implements WebBindingInitializer {
    @Override
    public void initBinder(WebDataBinder binder, WebRequest request) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(
    dateFormat, false));

    }
    复制代码

    并修改 servlet context xml配置文件

    复制代码
    <bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
    <bean
    class="net.zhepu.web.customerBinding.CustomerBinding" />
    </property>
    </bean>
    复制代码

    但这样一来就无法使用mvc:annotation-driven  了

  • 相关阅读:
    Django路由系统
    修改数据库时区问题
    Django框架篇
    前端css
    前端html
    前端初识
    数据库3
    数据库2
    数据库1
    数据库初识
  • 原文地址:https://www.cnblogs.com/fangyuan303687320/p/5306344.html
Copyright © 2011-2022 走看看