Java 类org.springframework.web.multipart.support.ByteArrayMultipartFileEditor 实例源码

项目:helium    文件:ExpedientMassivaController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Long.class,
            new CustomNumberEditor(Long.class, true));
    binder.registerCustomEditor(
            Double.class,
            new CustomNumberEditor(Double.class, true));
    binder.registerCustomEditor(
            BigDecimal.class,
            new CustomNumberEditor(
                    BigDecimal.class,
                    new DecimalFormat("#,##0.00"),
                    true));
    binder.registerCustomEditor(
            Boolean.class,
            new CustomBooleanEditor(false));
}
项目:ldadmin    文件:BaseFormController.java   
/**
 * Set up a custom property editor for converting form inputs to real
 * objects
 * 
 * @param request
 *            the current request
 * @param binder
 *            the data binder
 */
@InitBinder
protected void initBinder(HttpServletRequest request,
        ServletRequestDataBinder binder) {
    binder.registerCustomEditor(Integer.class, null,
            new CustomNumberEditor(Integer.class, null, true));
    binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(
            Long.class, null, true));
    binder.registerCustomEditor(byte[].class,
            new ByteArrayMultipartFileEditor());
    log.trace(request.getLocale());
    log.trace(getText("date.format", request.getLocale()));
    SimpleDateFormat dateFormat = new SimpleDateFormat(getText(
            "date.format", request.getLocale()));
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
            dateFormat, true));
}
项目:ankush    文件:BaseController.java   
/**
 * Set up a custom property editor for converting form inputs to real
 * objects.
 *
 * @param request the current request
 * @param binder the data binder
 */
@InitBinder
protected void initBinder(HttpServletRequest request,
        ServletRequestDataBinder binder) {
    binder.registerCustomEditor(Integer.class, null,
            new CustomNumberEditor(Integer.class, null, true));
    binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(
            Long.class, null, true));
    binder.registerCustomEditor(byte[].class,
            new ByteArrayMultipartFileEditor());
    SimpleDateFormat dateFormat = new SimpleDateFormat(
            "yyyy.MM.dd G 'at' HH:mm:ss z");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
            dateFormat, true));
}
项目:helium    文件:ExpedientTerminiV3Controller.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Long.class,
            new CustomNumberEditor(Long.class, true));
    binder.registerCustomEditor(
            Double.class,
            new CustomNumberEditor(Double.class, true));
    binder.registerCustomEditor(
            BigDecimal.class,
            new CustomNumberEditor(
                    BigDecimal.class,
                    new DecimalFormat("#,##0.00"),
                    true));
    binder.registerCustomEditor(
            Boolean.class,
            new CustomBooleanEditor(false));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:helium    文件:MassivaExpedientController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Long.class,
            new CustomNumberEditor(Long.class, true));
    binder.registerCustomEditor(
            Double.class,
            new CustomNumberEditor(Double.class, true));
    binder.registerCustomEditor(
            BigDecimal.class,
            new CustomNumberEditor(
                    BigDecimal.class,
                    new DecimalFormat("#,##0.00"),
                    true));
    binder.registerCustomEditor(
            Boolean.class,
            new CustomBooleanEditor(false));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:helium    文件:ExpedientV3Controller.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Long.class,
            new CustomNumberEditor(Long.class, true));
    binder.registerCustomEditor(
            Double.class,
            new CustomNumberEditor(Double.class, true));
    binder.registerCustomEditor(
            BigDecimal.class,
            new CustomNumberEditor(
                    BigDecimal.class,
                    new DecimalFormat("#,##0.00"),
                    true));
    binder.registerCustomEditor(
            Boolean.class,
            new CustomBooleanEditor(false));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:helium    文件:TascaDocumentsController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:helium    文件:ExpedientDocumentModificarController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:helium    文件:ExpedientDocumentAdjuntController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:helium    文件:ConsultaController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            ExpedientTipus.class,
            new ExpedientTipusTypeEditor(dissenyService));
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
}
项目:helium    文件:ExpedientTipusDocumentsController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            DefinicioProces.class,
            new DefinicioProcesTypeEditor(dissenyService));
    binder.registerCustomEditor(
            Camp.class,
            new CampTypeEditor(dissenyService));
}
项目:helium    文件:DefinicioProcesDocumentController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(
            DefinicioProces.class,
            new DefinicioProcesTypeEditor(dissenyService));
    binder.registerCustomEditor(
            Camp.class,
            new CampTypeEditor(dissenyService));
}
项目:communote-server    文件:ClientProfileController.java   
/**
 * {@inheritDoc}
 */
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
        throws ServletException {
    if (initBinderRequired) {
        // to actually be able to convert Multipart instance to byte[]
        // we have to register a custom editor
        binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
        // now Spring knows how to handle multipart object and convert them
    }
}
项目:communote-server    文件:AttachmentUploadController.java   
/**
 * {@inheritDoc}
 */
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
        throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:easyrec_major    文件:FileUploadController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:easyrec_major    文件:ClusterImportController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:spring-portlet-sample    文件:BooksController.java   
@InitBinder
protected void initBinder(PortletRequestDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    binder.setAllowedFields(new String[] {"author","title","description","availability","count","website","coverPng"});
}
项目:AlgoTrader    文件:GrailsDataBinder.java   
/**
 * Utility method for creating a GrailsDataBinder instance
 *
 * @param target The target object to bind to
 * @param objectName The name of the object
 * @return A GrailsDataBinder instance
 */
public static GrailsDataBinder createBinder(Object target, String objectName) {
    GrailsDataBinder binder = new GrailsDataBinder(target, objectName);
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
    binder.registerCustomEditor(Currency.class, new CurrencyEditor());
    binder.registerCustomEditor(Locale.class, new LocaleEditor());
    binder.registerCustomEditor(TimeZone.class, new TimeZoneEditor());
    binder.registerCustomEditor(URI.class, new UriEditor());

    registerCustomEditors(binder);

    return binder;
}
项目:webcurator    文件:TargetSeedsHandler.java   
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());

      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));

      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
项目:webcurator    文件:TreeToolController.java   
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());

      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Boolean.class, "propagateDelete", new CustomBooleanEditor(true));

      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
项目:Spring-Blog-Cms    文件:PostController.java   
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
        throws ServletException {

    // Convert multipart object to byte[]
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());

}
项目:easyrec-PoC    文件:FileUploadController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:easyrec-PoC    文件:ClusterImportController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:easyrec    文件:FileUploadController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:easyrec    文件:ClusterImportController.java   
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    // to actually be able to convert Multipart instance to byte[]
    // we have to register a custom editor
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    // now Spring knows how to handle multipart object and convert them
}
项目:kuali_rice    文件:UifConfigurableWebBindingInitializer.java   
@Override
public void initBinder(WebDataBinder binder, WebRequest request) {
    super.initBinder(binder, request);

    binder.registerCustomEditor(KualiDecimal.class, new UifCurrencyEditor());
    binder.registerCustomEditor(KualiInteger.class, new UifKualiIntegerCurrencyEditor());

    binder.registerCustomEditor(KualiPercent.class, new UifPercentageEditor());

    binder.registerCustomEditor(java.sql.Date.class, new UifDateEditor());
    binder.registerCustomEditor(java.util.Date.class, new UifDateEditor());
    binder.registerCustomEditor(Timestamp.class, new UifTimestampEditor());

    // TODO do we need this since we are switching to spring tags
    binder.registerCustomEditor(boolean.class, new UifBooleanEditor());
    binder.registerCustomEditor(Boolean.class, new UifBooleanEditor());
    binder.registerCustomEditor(Boolean.TYPE, new UifBooleanEditor());

    // Use the spring custom number editor for Big decimals
    DecimalFormat bigIntFormatter = new DecimalFormat();
    bigIntFormatter.setMaximumFractionDigits(340);
    binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, bigIntFormatter, true));
    binder.registerCustomEditor(AbstractKualiDecimal.class, new CustomNumberEditor(AbstractKualiDecimal.class,
            bigIntFormatter, true));

    // Use the spring StringTrimmerEditor editor for Strings
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));

    // Use the StringArrayPropertyEditor for string arrays with "," as the
    // separator
    binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(",", false));

    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
项目:termitaria    文件:PersonUploadPictureController.java   
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
            throws ServletException {
// to actually be able to convert Multipart instance to byte[]
// we have to register a custom editor
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
// now Spring knows how to handle multipart object and convert them
}
项目:termitaria    文件:ClientLogoChangeController.java   
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
            throws ServletException {
// to actually be able to convert Multipart instance to byte[]
// we have to register a custom editor
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
// now Spring knows how to handle multipart object and convert them
}
项目:helium    文件:ExpedientTipusConsultaController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
}
项目:helium    文件:DefinicioProcesDeployController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
}
项目:helium    文件:ExpedientTipusDeployController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            byte[].class,
            new ByteArrayMultipartFileEditor());
}
项目:RotaryLive    文件:AccessController.java   
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException {
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
项目:cacheonix-core    文件:PetDescriptionUploadController.java   
/**
 * Register the PropertyEditor for converting from a MultipartFile to an array of bytes.
 */
@InitBinder
public void registerMultipartEditor(WebDataBinder binder) {
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
项目:class-guard    文件:CommonsMultipartResolverTests.java   
private void doTestBinding(MockCommonsMultipartResolver resolver, MockHttpServletRequest originalRequest,
        MultipartHttpServletRequest request) throws UnsupportedEncodingException {

    MultipartTestBean1 mtb1 = new MultipartTestBean1();
    assertArrayEquals(null, mtb1.getField1());
    assertEquals(null, mtb1.getField2());
    ServletRequestDataBinder binder = new ServletRequestDataBinder(mtb1, "mybean");
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    binder.bind(request);
    List<MultipartFile> file1List = request.getFiles("field1");
    CommonsMultipartFile file1a = (CommonsMultipartFile) file1List.get(0);
    CommonsMultipartFile file1b = (CommonsMultipartFile) file1List.get(1);
    CommonsMultipartFile file2 = (CommonsMultipartFile) request.getFile("field2");
    assertEquals(file1a, mtb1.getField1()[0]);
    assertEquals(file1b, mtb1.getField1()[1]);
    assertEquals(new String(file2.getBytes()), new String(mtb1.getField2()));

    MultipartTestBean2 mtb2 = new MultipartTestBean2();
    assertArrayEquals(null, mtb2.getField1());
    assertEquals(null, mtb2.getField2());
    binder = new ServletRequestDataBinder(mtb2, "mybean");
    binder.registerCustomEditor(String.class, "field1", new StringMultipartFileEditor());
    binder.registerCustomEditor(String.class, "field2", new StringMultipartFileEditor("UTF-16"));
    binder.bind(request);
    assertEquals(new String(file1a.getBytes()), mtb2.getField1()[0]);
    assertEquals(new String(file1b.getBytes()), mtb2.getField1()[1]);
    assertEquals(new String(file2.getBytes(), "UTF-16"), mtb2.getField2());

    resolver.cleanupMultipart(request);
    assertTrue(((MockFileItem) file1a.getFileItem()).deleted);
    assertTrue(((MockFileItem) file1b.getFileItem()).deleted);
    assertTrue(((MockFileItem) file2.getFileItem()).deleted);

    resolver.setEmpty(true);
    request = resolver.resolveMultipart(originalRequest);
    binder.setBindEmptyMultipartFiles(false);
    String firstBound = mtb2.getField2();
    binder.bind(request);
    assertTrue(mtb2.getField2().length() > 0);
    assertEquals(firstBound, mtb2.getField2());

    request = resolver.resolveMultipart(originalRequest);
    binder.setBindEmptyMultipartFiles(true);
    binder.bind(request);
    assertTrue(mtb2.getField2().length() == 0);
}
项目:onecmdb    文件:IconGenerator.java   
@Override
protected void initBinder(ServletRequest request, ServletRequestDataBinder binder) throws Exception {
    super.initBinder(request, binder);

    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());

}
项目:OneCMDBwithMaven    文件:IconGenerator.java   
@Override
protected void initBinder(ServletRequest request, ServletRequestDataBinder binder) throws Exception {
    super.initBinder(request, binder);

    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());

}
项目:webapp    文件:AppCreateController.java   
/**
 * 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());
}
项目:webapp    文件:ApplicationVersionCreateController.java   
/**
 * 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());
}
项目:webapp    文件:AudioCreateController.java   
/**
 * 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());
}
项目:webapp    文件:AudioEditController.java   
/**
 * 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());
}