Search in sources :

Example 21 with InitBinder

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

the class ImageCreateController 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 22 with InitBinder

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

the class ImageEditController 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 23 with InitBinder

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

the class DqBaseController method initBinder.

@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
    DateFormat dateFormat = new SimpleDateFormat(DqDateFormatUtils.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)

Example 24 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project production_ssm by megagao.

the class FCountCheckController method InitBinder.

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

Example 25 with InitBinder

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

the class BillWebController method initBinder.

@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)

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