gpt4 book ai didi

org.springframework.web.bind.support.WebExchangeDataBinder.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 14:39:05 28 4
gpt4 key购买 nike

本文整理了Java中org.springframework.web.bind.support.WebExchangeDataBinder.<init>()方法的一些代码示例,展示了WebExchangeDataBinder.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebExchangeDataBinder.<init>()方法的具体详情如下:
包路径:org.springframework.web.bind.support.WebExchangeDataBinder
类名称:WebExchangeDataBinder
方法名:<init>

WebExchangeDataBinder.<init>介绍

[英]Create a new instance, with default object name.
[中]

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a {@link WebExchangeDataBinder} to apply data binding and
 * validation with on the target, command object.
 * @param exchange the current exchange
 * @param target the object to create a data binder for
 * @param name the name of the target object
 * @return the created data binder
 * @throws ServerErrorException if {@code @InitBinder} method invocation fails
 */
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, @Nullable Object target, String name) {
  WebExchangeDataBinder dataBinder = new WebExchangeDataBinder(target, name);
  if (this.initializer != null) {
    this.initializer.initBinder(dataBinder);
  }
  return initDataBinder(dataBinder, exchange);
}

代码示例来源:origin: spring-projects/spring-framework

@Before
public void setup() throws Exception {
  this.testBean = new TestBean();
  this.binder = new WebExchangeDataBinder(this.testBean, "person");
  this.binder.registerCustomEditor(ITestBean.class, new TestBeanPropertyEditor());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testMultipart() throws Exception {
  MultipartBean bean = new MultipartBean();
  WebExchangeDataBinder binder = new WebExchangeDataBinder(bean);
  MultiValueMap<String, Object> data = new LinkedMultiValueMap<>();
  data.add("name", "bar");
  data.add("someList", "123");
  data.add("someList", "abc");
  data.add("someArray", "dec");
  data.add("someArray", "456");
  data.add("part", new ClassPathResource("org/springframework/http/codec/multipart/foo.txt"));
  data.add("somePartList", new ClassPathResource("org/springframework/http/codec/multipart/foo.txt"));
  data.add("somePartList", new ClassPathResource("org/springframework/http/server/reactive/spring.png"));
  binder.bind(exchangeMultipart(data)).block(Duration.ofMillis(5000));
  assertEquals("bar", bean.getName());
  assertEquals(Arrays.asList("123", "abc"), bean.getSomeList());
  assertArrayEquals(new String[] {"dec", "456"}, bean.getSomeArray());
  assertEquals("foo.txt", bean.getPart().filename());
  assertEquals(2, bean.getSomePartList().size());
  assertEquals("foo.txt", bean.getSomePartList().get(0).filename());
  assertEquals("spring.png", bean.getSomePartList().get(1).filename());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void requestMappingHandlerAdapter() throws Exception {
  ApplicationContext context = loadConfig(WebFluxConfig.class);
  String name = "requestMappingHandlerAdapter";
  RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
  assertNotNull(adapter);
  List<HttpMessageReader<?>> readers = adapter.getMessageReaders();
  assertEquals(13, readers.size());
  ResolvableType multiValueMapType = forClassWithGenerics(MultiValueMap.class, String.class, String.class);
  assertHasMessageReader(readers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
  assertHasMessageReader(readers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
  assertHasMessageReader(readers, forClass(String.class), TEXT_PLAIN);
  assertHasMessageReader(readers, forClass(Resource.class), IMAGE_PNG);
  assertHasMessageReader(readers, forClass(Message.class), new MediaType("application", "x-protobuf"));
  assertHasMessageReader(readers, multiValueMapType, APPLICATION_FORM_URLENCODED);
  assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_XML);
  assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_JSON);
  assertHasMessageReader(readers, forClass(TestBean.class), new MediaType("application", "x-jackson-smile"));
  assertHasMessageReader(readers, forClass(TestBean.class), null);
  WebBindingInitializer bindingInitializer = adapter.getWebBindingInitializer();
  assertNotNull(bindingInitializer);
  WebExchangeDataBinder binder = new WebExchangeDataBinder(new Object());
  bindingInitializer.initBinder(binder);
  name = "webFluxConversionService";
  ConversionService service = context.getBean(name, ConversionService.class);
  assertSame(service, binder.getConversionService());
  name = "webFluxValidator";
  Validator validator = context.getBean(name, Validator.class);
  assertSame(validator, binder.getValidator());
}

代码示例来源:origin: org.springframework/spring-web-reactive

/**
 * Create the data binder instance.
 */
protected WebExchangeDataBinder createBinderInstance(Object target, String objectName) {
  return new WebExchangeDataBinder(target, objectName);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com