本文整理了Java中org.springframework.web.bind.support.WebBindingInitializer.initBinder()
方法的一些代码示例,展示了WebBindingInitializer.initBinder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebBindingInitializer.initBinder()
方法的具体详情如下:
包路径:org.springframework.web.bind.support.WebBindingInitializer
类名称:WebBindingInitializer
方法名:initBinder
[英]Initialize the given DataBinder for the given (Servlet) request.
[中]为给定的(Servlet)请求初始化给定的DataBinder。
代码示例来源:origin: spring-projects/spring-framework
/**
* Initialize the given DataBinder for the given (Servlet) request.
* @param binder the DataBinder to initialize
* @param request the web request that the data binding happens within
* @deprecated as of 5.0 in favor of {@link #initBinder(WebDataBinder)}
*/
@Deprecated
default void initBinder(WebDataBinder binder, WebRequest request) {
initBinder(binder);
}
代码示例来源:origin: org.springframework/spring-web
/**
* Initialize the given DataBinder for the given (Servlet) request.
* @param binder the DataBinder to initialize
* @param request the web request that the data binding happens within
* @deprecated as of 5.0 in favor of {@link #initBinder(WebDataBinder)}
*/
@Deprecated
default void initBinder(WebDataBinder binder, WebRequest request) {
initBinder(binder);
}
代码示例来源: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
/**
* Create a new {@link WebDataBinder} for the given target object and
* initialize it through a {@link WebBindingInitializer}.
* @throws Exception in case of invalid state or arguments
*/
@Override
@SuppressWarnings("deprecation")
public final WebDataBinder createBinder(
NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception {
WebDataBinder dataBinder = createBinderInstance(target, objectName, webRequest);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder, webRequest);
}
initBinder(dataBinder, webRequest);
return dataBinder;
}
代码示例来源:origin: org.springframework/spring-web
/**
* Create a new {@link WebDataBinder} for the given target object and
* initialize it through a {@link WebBindingInitializer}.
* @throws Exception in case of invalid state or arguments
*/
@Override
@SuppressWarnings("deprecation")
public final WebDataBinder createBinder(
NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception {
WebDataBinder dataBinder = createBinderInstance(target, objectName, webRequest);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder, webRequest);
}
initBinder(dataBinder, webRequest);
return dataBinder;
}
代码示例来源: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: apache/servicemix-bundles
/**
* Initialize the given DataBinder for the given (Servlet) request.
* @param binder the DataBinder to initialize
* @param request the web request that the data binding happens within
* @deprecated as of 5.0 in favor of {@link #initBinder(WebDataBinder)}
*/
@Deprecated
default void initBinder(WebDataBinder binder, WebRequest request) {
initBinder(binder);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
/**
* Initialize the given DataBinder for the given (Servlet) request.
* @param binder the DataBinder to initialize
* @param request the web request that the data binding happens within
* @deprecated as of 5.0 in favor of {@link #initBinder(WebDataBinder)}
*/
@Deprecated
default void initBinder(WebDataBinder binder, WebRequest request) {
initBinder(binder);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Initialize the given binder instance, for example with custom editors.
* Called by {@code createBinder}.
* <p>This method allows you to register custom editors for certain fields of your
* command class. For instance, you will be able to transform Date objects into a
* String pattern and back, in order to allow your JavaBeans to have Date properties
* and still be able to set and display them in an HTML interface.
* <p>The default implementation is empty.
* <p>Note: the command object is not directly passed to this method, but it's available
* via {@link org.springframework.validation.DataBinder#getTarget()}
* @param request current HTTP request
* @param binder new binder instance
* @throws Exception in case of invalid state or arguments
* @see #createBinder
* @see org.springframework.validation.DataBinder#registerCustomEditor
* @see org.springframework.beans.propertyeditors.CustomDateEditor
*/
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
if (this.webBindingInitializer != null) {
this.webBindingInitializer.initBinder(binder, new ServletWebRequest(request));
}
}
代码示例来源:origin: org.springframework/org.springframework.web.portlet
/**
* Initialize the given binder instance, for example with custom editors.
* Called by <code>createBinder</code>.
* <p>This method allows you to register custom editors for certain fields of your
* command class. For instance, you will be able to transform Date objects into a
* String pattern and back, in order to allow your JavaBeans to have Date properties
* and still be able to set and display them in an HTML interface.
* <p>The default implementation is empty.
* @param request current portlet request
* @param binder new binder instance
* @throws Exception in case of invalid state or arguments
* @see #createBinder
* @see org.springframework.validation.DataBinder#registerCustomEditor
* @see org.springframework.beans.propertyeditors.CustomDateEditor
*/
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) throws Exception {
if (this.webBindingInitializer != null) {
this.webBindingInitializer.initBinder(binder, new PortletWebRequest(request));
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
/**
* Create a new {@link WebDataBinder} for the given target object and
* initialize it through a {@link WebBindingInitializer}.
* @throws Exception in case of invalid state or arguments
*/
@Override
@SuppressWarnings("deprecation")
public final WebDataBinder createBinder(
NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception {
WebDataBinder dataBinder = createBinderInstance(target, objectName, webRequest);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder, webRequest);
}
initBinder(dataBinder, webRequest);
return dataBinder;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Create a new {@link WebDataBinder} for the given target object and
* initialize it through a {@link WebBindingInitializer}.
* @throws Exception in case of invalid state or arguments
*/
@Override
@SuppressWarnings("deprecation")
public final WebDataBinder createBinder(
NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception {
WebDataBinder dataBinder = createBinderInstance(target, objectName, webRequest);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder, webRequest);
}
initBinder(dataBinder, webRequest);
return dataBinder;
}
代码示例来源:origin: org.springframework/spring-web-reactive
/**
* Create a {@link WebExchangeDataBinder} for applying data binding, type
* conversion, and validation on the given "target" 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 {@link WebExchangeDataBinder} instance
*/
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, Object target, String name) {
WebExchangeDataBinder dataBinder = createBinderInstance(target, name);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder);
}
return initDataBinder(dataBinder, exchange);
}
代码示例来源:origin: apache/servicemix-bundles
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);
}
}
}
}
}
}
代码示例来源:origin: org.parancoe/parancoe-web
this.bindingInitializer.initBinder(binder, webRequest);
代码示例来源:origin: philwebb/springfaces
WebRequest request = new FacesWebRequest(FacesContext.getCurrentInstance());
if (this.context.getWebBindingInitializer() != null) {
this.context.getWebBindingInitializer().initBinder(binder, request);
内容来源于网络,如有侵权,请联系作者删除!