Search in sources :

Example 1 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project webapp by elimu-ai.

the class AppCreateController method initBinder.

/**
 * See http://www.mkyong.com/spring-mvc/spring-mvc-failed-to-convert-property-value-in-file-upload-form/
 * <p></p>
 * Fixes this error message:
 * "Cannot convert value of type [org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile] to required type [byte] for property 'bytes[0]'"
 */
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    logger.info("initBinder");
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
Also used : ByteArrayMultipartFileEditor(org.springframework.web.multipart.support.ByteArrayMultipartFileEditor) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 2 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 3 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project dq-easy-cloud by dq-open-cloud.

the class EcBaseController method initBinder.

@EcLogAnnotation(logSwitch = false, analysisSwitch = false)
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
    DateFormat dateFormat = new SimpleDateFormat(EcDateFormatUtils.FORMAT_NORMAL_DAY);
    webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
// webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat(DqDateFormatUtils.FORMAT_NORMAL), true));
}
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) EcLogAnnotation(com.easy.cloud.core.common.log.annotation.EcLogAnnotation)

Example 4 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project incubator-dubbo-ops by apache.

the class ApiDocsController method initBinder.

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    binder.registerCustomEditor(LocalDate.class, new CustomLocalDateEditor());
    binder.registerCustomEditor(LocalDateTime.class, new CustomLocalDateTimeEditor());
}
Also used : StringTrimmerEditor(org.springframework.beans.propertyeditors.StringTrimmerEditor) CustomLocalDateEditor(org.apache.dubbo.admin.controller.editors.CustomLocalDateEditor) CustomLocalDateTimeEditor(org.apache.dubbo.admin.controller.editors.CustomLocalDateTimeEditor) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 5 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)

Aggregations

InitBinder (org.springframework.web.bind.annotation.InitBinder)39 SimpleDateFormat (java.text.SimpleDateFormat)14 CustomDateEditor (org.springframework.beans.propertyeditors.CustomDateEditor)14 ByteArrayMultipartFileEditor (org.springframework.web.multipart.support.ByteArrayMultipartFileEditor)10 DateFormat (java.text.DateFormat)7 StringTrimmerEditor (org.springframework.beans.propertyeditors.StringTrimmerEditor)4 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 EcLogAnnotation (com.easy.cloud.core.common.log.annotation.EcLogAnnotation)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 CustomLocalDateEditor (org.apache.dubbo.admin.controller.editors.CustomLocalDateEditor)1 CustomLocalDateTimeEditor (org.apache.dubbo.admin.controller.editors.CustomLocalDateTimeEditor)1 NonNullBooleanEditor (org.broadleafcommerce.openadmin.web.editor.NonNullBooleanEditor)1 FlowEncapsulationType (org.openkilda.model.FlowEncapsulationType)1