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

BaseController.java 文件源码 项目:osframe 阅读 37 收藏 0 点赞 0 评论 0
/**
 * 表单中其他格式传入前先解析
 *  如时间类型
 * @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);

}
ServletApplicationContextConfig.java 文件源码 项目:bookManager 阅读 31 收藏 0 点赞 0 评论 0
@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);
}
CommonControllerAdvice.java 文件源码 项目:oma-riista-web 阅读 31 收藏 0 点赞 0 评论 0
@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()));
    }
}
ServletAnnotationControllerHandlerMethodTests.java 文件源码 项目:spring4-understanding 阅读 39 收藏 0 点赞 0 评论 0
@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));
}
PersonalUpdateController.java 文件源码 项目:Spring-MVC-Blueprints 阅读 28 收藏 0 点赞 0 评论 0
@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());
}
UriTemplateServletAnnotationControllerTests.java 文件源码 项目:spring4-understanding 阅读 30 收藏 0 点赞 0 评论 0
@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));
}
ServletAnnotationControllerTests.java 文件源码 项目:spring4-understanding 阅读 41 收藏 0 点赞 0 评论 0
@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));
}
OffersController.java 文件源码 项目:cmc-claim-store 阅读 31 收藏 0 点赞 0 评论 0
@InitBinder
public void initWebDataBinder(WebDataBinder webDataBinder) {
    webDataBinder.registerCustomEditor(MadeBy.class, new MadeByEnumConverter());
}
EmployeeController.java 文件源码 项目:Spring-5.0-Cookbook 阅读 33 收藏 0 点赞 0 评论 0
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){

    binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
    binder.registerCustomEditor(Date.class, new DateEditor());
}
EmployeeController.java 文件源码 项目:Spring-5.0-Cookbook 阅读 31 收藏 0 点赞 0 评论 0
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){

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


问题


面经


文章

微信
公众号

扫码关注公众号