Package com.common.platform.spring

Source Code of com.common.platform.spring.CustomWebBindingInitializer

/*
* 文件名:CommonWebBindingInitializer.java
* 版权:Copyright 2012-2013 SOHO League. All Rights Reserved.
* 描述: 公共平台
* 修改人:
* 修改时间:
* 跟踪单号:
* 修改单号:
* 修改内容:
*/
package com.common.platform.spring;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

/**
* 功能描述:<code>CustomWebBindingInitializer</code>提供web元素编辑器自定义绑定功能。<p>
*
* @author   andy.zheng
* @version  1.0, 2013-12-26 下午3:30:08
* @since    CommonPlatform 1.0
*/
public class CustomWebBindingInitializer implements WebBindingInitializer {

    public void initBinder(final WebDataBinder binder, final WebRequest request) {
        final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
        binder.registerCustomEditor(Short.class, new CustomNumberEditor(Short.class, true));
        binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, true));
        binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true));
        binder.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, true));
        binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, true));
        binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true));
        binder.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));
    }
}
TOP

Related Classes of com.common.platform.spring.CustomWebBindingInitializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.