Java 类org.springframework.web.bind.annotation.InitBinder 实例源码

项目:helium    文件:TascaTramitacioController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    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(true));
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:Spring-5.0-Cookbook    文件:FormController.java   
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){
    binder.setValidator(employeeValidator);

    binder.registerCustomEditor(Date.class, new DateEditor());
    binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
}
项目:Spring-5.0-Cookbook    文件:FormController.java   
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){
    binder.setValidator(employeeValidator);

    binder.registerCustomEditor(Date.class, new DateEditor());
    binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
}
项目:helium    文件:ExpedientTokenV3Controller.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    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(true));
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:helium    文件:ExpedientConsultaLlistatController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.setAutoGrowNestedPaths(false);
    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(true));
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目: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));
}
项目:helium    文件:ExpedientIniciarPasFormController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    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(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:helium    文件:ExpedientConsultaDissenyController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.setAutoGrowNestedPaths(false);
    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(true));
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:helium    文件:CommonRegistreController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    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(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:helium    文件:ExpedientDadaModificarController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    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(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:spring-boot    文件:GlobalControllerAdvice.java   
/***
     * @param binder
     * @InitBinder 用来配置全局 Controller ,设置 WebDataBinder,WebDataBinder 用来自动绑定前台请求参数到 Model 中。
     */
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        //忽略 request 中的参数 dis ,更多关于 WebDataBinder ,可参考文档。
        //binder.setDisallowedFields("dis");
//        binder.registerCustomEditor(LocalDate.class, new PropertyEditorSupport() {
//            @Override
//            public void setAsText(String text) throws IllegalArgumentException {
//                LocalDate.parse(text, DateTimeFormatter.ISO_DATE);
//            }
//        });  //自动绑定 LocalDate
//
//        @GetMapping
//        public ResponseEntity<List<Order>> getOrdersByDate(
//                @RequestParam(name = "date")LocalDate date) {
//            // retrieve and return orders by date
//        }

    }
项目:dss-demonstrations    文件:SignatureMultipleDocumentsController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
    binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
    binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
    binder.registerCustomEditor(DigestAlgorithm.class, new EnumPropertyEditor(DigestAlgorithm.class));
    binder.registerCustomEditor(EncryptionAlgorithm.class, new EnumPropertyEditor(EncryptionAlgorithm.class));
}
项目:dss-demonstrations    文件:SignatureController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
    binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
    binder.registerCustomEditor(SignaturePackaging.class, new EnumPropertyEditor(SignaturePackaging.class));
    binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
    binder.registerCustomEditor(DigestAlgorithm.class, new EnumPropertyEditor(DigestAlgorithm.class));
    binder.registerCustomEditor(EncryptionAlgorithm.class, new EnumPropertyEditor(EncryptionAlgorithm.class));
}
项目:dss-demonstrations    文件:ExtensionController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
    binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
    binder.registerCustomEditor(SignaturePackaging.class, new EnumPropertyEditor(SignaturePackaging.class));
    binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
}
项目:profile-manager    文件:AdministrationInformationController.java   
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
   binder.registerCustomEditor(Category.class, "categorySet", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) {
         Category category = categoryService.findByPK(Long.parseLong(text));
         setValue(category);
      }
   });
}
项目:profile-manager    文件:AdministrationUserController.java   
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
   binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) {
         Role role = roleService.findByPK(Long.parseLong(text));
         setValue(role);
      }
   });
}
项目:lams    文件:HandlerMethodInvoker.java   
protected void initBinder(Object handler, String attrName, WebDataBinder binder, NativeWebRequest webRequest)
        throws Exception {

    if (this.bindingInitializer != null) {
        this.bindingInitializer.initBinder(binder, webRequest);
    }
    if (handler != null) {
        Set<Method> initBinderMethods = this.methodResolver.getInitBinderMethods();
        if (!initBinderMethods.isEmpty()) {
            boolean debug = logger.isDebugEnabled();
            for (Method initBinderMethod : initBinderMethods) {
                Method methodToInvoke = BridgeMethodResolver.findBridgedMethod(initBinderMethod);
                String[] targetNames = AnnotationUtils.findAnnotation(initBinderMethod, InitBinder.class).value();
                if (targetNames.length == 0 || Arrays.asList(targetNames).contains(attrName)) {
                    Object[] initBinderArgs =
                            resolveInitBinderArguments(handler, methodToInvoke, binder, webRequest);
                    if (debug) {
                        logger.debug("Invoking init-binder method: " + methodToInvoke);
                    }
                    ReflectionUtils.makeAccessible(methodToInvoke);
                    Object returnValue = methodToInvoke.invoke(handler, initBinderArgs);
                    if (returnValue != null) {
                        throw new IllegalStateException(
                                "InitBinder methods must not have a return value: " + methodToInvoke);
                    }
                }
            }
        }
    }
}
项目:spring-grow    文件:AdministrationUserController.java   
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
   binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) {
         Role role = roleService.findByPK(Long.parseLong(text));
         setValue(role);
      }
   });
}
项目:xmanager    文件:BaseController.java   
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
    /**
     * 自动转换日期类型的字段格式
     */
    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));
    /**
     * 防止XSS攻击
     */
    binder.registerCustomEditor(String.class, new StringEscapeEditor());
}
项目:xmanager    文件:BaseController.java   
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
    /**
     * 自动转换日期类型的字段格式
     */
    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));
    /**
     * 防止XSS攻击
     */
    binder.registerCustomEditor(String.class, new StringEscapeEditor());
}
项目:https-github.com-in28minutes-SpringIn28Minutes    文件:TodoController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(
            TodoListUtils.DATE_FORMAT);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(
            dateFormat, false));
    binder.registerCustomEditor(Priority.class,
            new TodoPriorityPropertyEditor());
}
项目: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());
}
项目:springlets    文件:StringTrimmerAdvice.java   
/**
 * Registers the {@link StringTrimmerEditor}
 *
 * @param webDataBinder
 */
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
  StringTrimmerEditor trimmer =
      new StringTrimmerEditor(this.getCharsToDelete(), this.isEmptyAsNull());
  webDataBinder.registerCustomEditor(String.class, trimmer);
}
项目: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    文件:ExpedientTipusController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
项目:helium    文件:TascaLlistatV3Controller.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(
            Object.class,
            new ObjectTypeEditorHelper());
}
项目:ams    文件:BaseController.java   
@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(
            dateFormat, true));
}
项目:helium    文件:ExpedientLlistatController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
项目:helium    文件:PerfilController.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
            boolean.class,
            new CustomBooleanEditor(false));
    binder.registerCustomEditor(
            Date.class,
            new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
项目:spring4-understanding    文件:ServletAnnotationControllerHandlerMethodTests.java   
@SuppressWarnings("unused")
@InitBinder({"myCommand", "date"})
private void initBinder(WebDataBinder binder, String date, @RequestParam("date") String[] date2) {
    LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
    vf.afterPropertiesSet();
    binder.setValidator(vf);
    assertEquals("2007-10-02", date);
    assertEquals(1, date2.length);
    assertEquals("2007-10-02", date2[0]);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
项目:osframe    文件:BaseController.java   
/**
 * 表单中其他格式传入前先解析
 *  如时间类型
 * @param request
 * @param binder
 * @throws Exception
 */
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    //对于需要转换为Date类型的属性,使用DateEditor进行处理
    binder.registerCustomEditor(Date.class, new DateEditor());
    //获取实体类,然后初始化去获取其特定的转换方式
    IBaseDomain baseDomain=(IBaseDomain)getServiceImp().getBaseDao().getDomainClass().newInstance();
    baseDomain.convertFields( request,  binder);

}
项目:bookManager    文件:ServletApplicationContextConfig.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    sdf.setLenient(true);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
    binder.setValidator(this.validator);
}
项目:oma-riista-web    文件:CommonControllerAdvice.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    Object target = binder.getTarget();
    if (target != null) {
        binder.replaceValidators(supportedValidatorsFor(target.getClass()));
    }
}
项目:spring4-understanding    文件:ServletAnnotationControllerHandlerMethodTests.java   
@SuppressWarnings("unused")
@InitBinder
private void initBinder(WebDataBinder binder) {
    binder.initBeanPropertyAccess();
    binder.setRequiredFields("sex");
    LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
    vf.afterPropertiesSet();
    binder.setValidator(vf);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
项目:Spring-MVC-Blueprints    文件:PersonalUpdateController.java   
@InitBinder("personForm")
public void initBinder(WebDataBinder binder) {
    binder.setValidator(personalValidator);
    binder.registerCustomEditor(Integer.class, "biography.age",
            new AgeConverter());
    binder.registerCustomEditor(Integer.class, "education.year",
            new YearConverter());
    binder.registerCustomEditor(Date.class, "biography.birthDate",
            new BirthDateConverter());
}
项目:spring4-understanding    文件:UriTemplateServletAnnotationControllerTests.java   
@InitBinder
public void initBinder(WebDataBinder binder, @PathVariable("hotel") String hotel) {
    assertEquals("Invalid path variable value", "42", hotel);
    binder.initBeanPropertyAccess();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
项目:spring4-understanding    文件:ServletAnnotationControllerTests.java   
@SuppressWarnings("unused")
@InitBinder
private void initBinder(WebDataBinder binder) {
    binder.initBeanPropertyAccess();
    binder.setRequiredFields("sex");
    LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
    vf.afterPropertiesSet();
    binder.setValidator(vf);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
项目:cmc-claim-store    文件:OffersController.java   
@InitBinder
public void initWebDataBinder(WebDataBinder webDataBinder) {
    webDataBinder.registerCustomEditor(MadeBy.class, new MadeByEnumConverter());
}
项目:Spring-5.0-Cookbook    文件:EmployeeController.java   
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){

    binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
    binder.registerCustomEditor(Date.class, new DateEditor());
}
项目:Spring-5.0-Cookbook    文件:EmployeeController.java   
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){

    binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
    binder.registerCustomEditor(Date.class, new DateEditor());
}