Search in sources :

Example 6 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project portal by ixinportal.

the class ClientWebController method initBinder.

/**
 * 自动时间格式转换
 * @param binder
 * @throws Exception
 */
@InitBinder
public void initBinder(WebDataBinder binder) throws Exception {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    CustomDateEditor dateEditor = new CustomDateEditor(df, true);
    binder.registerCustomEditor(Date.class, dateEditor);
}
Also used : CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 7 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project spring-integration-samples by spring-projects.

the class SharkController method registerConverters.

@InitBinder
void registerConverters(WebDataBinder binder) {
    if (binder.getConversionService() instanceof GenericConversionService) {
        GenericConversionService conversionService = (GenericConversionService) binder.getConversionService();
        conversionService.addConverter(getLoanSharkConverter());
    }
}
Also used : GenericConversionService(org.springframework.core.convert.support.GenericConversionService) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 8 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project xxl-job by xuxueli.

the class IndexController method initBinder.

@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
Also used : CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) SimpleDateFormat(java.text.SimpleDateFormat) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 9 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project steve by RWTH-i5-IDSG.

the class GlobalControllerAdvice method binder.

@InitBinder
public void binder(WebDataBinder binder) {
    BatchInsertConverter batchInsertConverter = new BatchInsertConverter();
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    binder.registerCustomEditor(LocalDate.class, new LocalDateEditor());
    binder.registerCustomEditor(LocalDateTime.class, new LocalDateTimeEditor());
    binder.registerCustomEditor(ChargePointSelect.class, new ChargePointSelectEditor());
    binder.registerCustomEditor(List.class, "idList", batchInsertConverter);
    binder.registerCustomEditor(List.class, "recipients", batchInsertConverter);
}
Also used : StringTrimmerEditor(org.springframework.beans.propertyeditors.StringTrimmerEditor) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 10 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project spring_boot by hryou0922.

the class FloatEditor method initBinder.

/**
 * 此绑定只对输入的属性通过指定的CustomDateEditor执行解析,
 * 但是不对返回客户端的属性进行解析
 *
 * @param binder
 */
// 必须有一个参数WebDataBinder
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), false));
    // 注释此句:对特定的属性,进行解析
    // binder.registerCustomEditor(Date.class, "shortDate",new CustomDateEditor(new SimpleDateFormat("yyyy-MM"), false));
    binder.registerCustomEditor(Integer.class, new IntegerEditor());
    binder.registerCustomEditor(Float.class, new FloatEditor());
}
Also used : CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) SimpleDateFormat(java.text.SimpleDateFormat) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Aggregations

InitBinder (org.springframework.web.bind.annotation.InitBinder)35 SimpleDateFormat (java.text.SimpleDateFormat)13 CustomDateEditor (org.springframework.beans.propertyeditors.CustomDateEditor)13 ByteArrayMultipartFileEditor (org.springframework.web.multipart.support.ByteArrayMultipartFileEditor)9 DateFormat (java.text.DateFormat)6 StringTrimmerEditor (org.springframework.beans.propertyeditors.StringTrimmerEditor)3 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)3 PropertyEditorSupport (java.beans.PropertyEditorSupport)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2 DateTimeFormatterBuilder (org.joda.time.format.DateTimeFormatterBuilder)2 DateConvertEditor (com.cdeledu.core.interceptors.DateConvertEditor)1 TodoPriorityPropertyEditor (com.in28minutes.springmvc.web.util.TodoPriorityPropertyEditor)1 DateTimePropertyEditorSupport (hry.core.util.springmvcPropertyeditor.DateTimePropertyEditorSupport)1 StringPropertyEditorSupport (hry.core.util.springmvcPropertyeditor.StringPropertyEditorSupport)1 NumberFormat (java.text.NumberFormat)1 NonNullBooleanEditor (org.broadleafcommerce.openadmin.web.editor.NonNullBooleanEditor)1 CustomNumberEditor (org.springframework.beans.propertyeditors.CustomNumberEditor)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 DefinitionTypeConverter (org.talend.components.service.rest.DefinitionTypeConverter)1 ConnectorTypologyConverter (org.talend.components.service.rest.dto.ConnectorTypologyConverter)1